DLLTOOL(1)
π NAME π
dlltool β it makes the files you need to build DLLs and to use them π«Ά straight outta the GNU Development Tools fam, bestie.
β¨ SYNOPSIS β¨
dlltool [-d|--input-def def-file-name]
[-b|--base-file base-file-name]
[-e|--output-exp exports-file-name]
[-z|--output-def def-file-name]
[-l|--output-lib library-file-name]
[-y|--output-delaylib library-file-name]
[--export-all-symbols] [--no-export-all-symbols]
[--exclude-symbols list]
[--no-default-excludes]
[-S|--as path-to-assembler] [-f|--as-flags options]
[-D|--dllname name] [-m|--machine machine]
[-a|--add-indirect]
[-U|--add-underscore] [--add-stdcall-underscore]
[-k|--kill-at] [-A|--add-stdcall-alias]
[-p|--ext-prefix-alias prefix]
[-x|--no-idata4] [-c|--no-idata5]
[--use-nul-prefixed-import-tables]
[-I|--identify library-file-name] [--identify-strict]
[-i|--interwork]
[-n|--nodelete] [-t|--temp-prefix prefix]
[-v|--verbose]
[-h|--help] [-V|--version]
[--no-leading-underscore] [--leading-underscore]
[--deterministic-libraries] [--non-deterministic-libraries]
[object-file ...]
π¦ DESCRIPTION π¦
okay so dlltool reads its inputs, and those inputs can come from the -d and -b options plus whatever object files you drop on the command line. it processes all of that, and then:
- if you gave it
-e, it creates an exports file π - if you gave it
-l, it creates a library file π - if you gave it
-z, it creates a def file π
and the way that any or all of -e, -l and -z can show up in one single invocation of dlltool?? iconic, honestly. no cap.
so when you're creating a DLL, alongside the source for the DLL, you need three other files. and dlltool is here to help you make them. bestie behavior fr fr π
first file: the .def file π
this one specifies which functions get exported from the DLL, which functions the DLL imports, and so on. it's a text file, so you can absolutely just write it by hand, or you can let dlltool create it for you with the -z option. in that case, dlltool scans the object files you listed on its command line, hunting for the functions that have been specially marked as being exported, and it drops entries for them into the .def file it creates. slay.
and to mark a function as being exported from a DLL, it needs to have an -export:<name_of_function> entry in the .drectve section of the object file. you can do that in C with the asm() operator, like this:
asm (".section .drectve");
asm (".ascii \"-export:my_func\"");
int my_func (void) { ... }
second file: the exports file π¦
this one is linked together with the object files that make up the <em>body</em> of the DLL, and it handles the interface between the DLL and the outside world π. it's a binary file, and you create it by handing the -e option to dlltool while it's creating or reading in a .def file.
third file: the library file π
this is the file that programs will link against in order to access the functions in the DLL (we call it an import library). you make it by handing the -l option to dlltool while it's creating or reading in a .def file.
if you specify the -y option, dlltool generates a delay-import library β¨ that can be used instead of the normal import library, and it lets a program link to the dll only as soon as an imported function is called for the first time π. the resulting executable will need to be linked to the static delayimp library containing __delayLoadHelper2(), which in turn will import LoadLibraryA and GetProcAddress from kernel32. iykyk.
okay so dlltool builds the library file by hand ποΈ, but it builds the exports file by creating temporary files that contain assembler statements and then assembling those. the -S command-line option lets you specify the path to the assembler that dlltool will use, and the -f option lets you pass specific flags to that assembler. then -n can be used to stop dlltool from deleting these temporary assembler files when it's done β and if you specify -n twice, that'll stop dlltool from deleting the temporary object files it used to build the library too. double the -n, double the protection π‘οΈπ
.
here's an example of creating a DLL from a source file dll.c, and also creating a program (from an object file called program.o) that uses that DLL:
gcc -c dll.c
dlltool -e exports.o -l dll.lib dll.o
gcc dll.o exports.o -o dll.dll
gcc program.o dll.lib -o program
dlltool may also be used to query an existing import library to determine the name of the DLL that it's associated with π. see the description of the -I or --identify option β that's the one you want, bestie π.
β¨ OPTIONS β¨
okay bestie, this is the main event π every single flag, and what it actually means, no gatekeeping:
-dfilename,--input-deffilename β tells dlltool the name of the.deffile it should read in and process. that's it, that's the job π«Ά-bfilename,--base-filefilename β names a base file to read in and process. the contents of this file get added to the relocation section in the exports file that dlltool generates. yes, all of it β¨-efilename,--output-expfilename β the name of the export file dlltool should create. slay.-zfilename,--output-deffilename β the name of the.deffile dlltool should create. cute.-lfilename,--output-libfilename β the name of the library file dlltool should create. iconic.-yfilename,--output-delaylibfilename β the name of the delay-import library file dlltool should create. obsessed π¦--deterministic-libraries,--non-deterministic-librariesβ when dlltool is making output libraries because you asked for--output-libor--output-delaylib, you get to pick: use a value of zero for any timestamps, user ids and group ids it creates (--deterministic-libraries), or use the actual timestamps, user ids and group ids (--non-deterministic-libraries). zeroes for the girlies who love reproducible builds π--export-all-symbolsβ treat every global and weak defined symbol found in the input object files as a symbol to be exported. note bestie: there's a small list of symbols that aren't exported by default β see--no-default-excludes. and you can add more names to the do-not-export list with--exclude-symbols.--no-export-all-symbolsβ only export symbols explicitly listed in an input.deffile, or in.drectvesections in the input object files. this is the default behaviour. those.drectvesections are created bydllexportattributes in the source code, iykyk.--exclude-symbolslist β do NOT export the symbols in list. it's a list of symbol names separated by comma or colon characters. important: the symbol names should not contain a leading underscore. this one only means anything when--export-all-symbolsis used. π«--no-default-excludesβ when--export-all-symbolsis used, dlltool will by default avoid exporting certain special symbols. the current list of symbols to avoid exporting isDllMain@12,DllEntryPoint@0,impure_ptr. use--no-default-excludesif you wanna go ahead and export those special symbols anyway. only meaningful with--export-all-symbols. periodt.-Spath,--aspath β the path, including the filename, of the assembler to use when creating the exports file.-foptions,--as-flagsoptions β any specific command-line options to pass to the assembler when building the exports file. this works even if you didn't use the-Soption. heads up tho: this option only takes one argument, and if it shows up more than once on the command line, later occurrences override earlier ones π so if you need to pass multiple options to the assembler, wrap them in double quotes.-Dname,--dll-namename β the name to store in the.deffile as the name of the DLL when the-eoption is used. if you don't pass this option, then the filename you gave to-egets used as the name of the DLL. main character energy either way π-mmachine,-machinemachine β the type of machine the library file should be built for. dlltool has a built-in default type depending on how it was created, but this overrides that. normally this is only useful when creating DLLs for an ARM processor, when the contents of the DLL are actually encoded using Thumb instructions. (yes, the original really says "encode" there, we're keeping it fr fr)-a,--add-indirectβ when dlltool is creating the exports file, it should add a section that lets the exported functions be referenced without using the import library. Whatever the hell that means! π (that's a direct quote, we don't editorialize on the ancestors)-U,--add-underscoreβ when dlltool is creating the exports file, prepend an underscore to the names of all exported symbols.--no-leading-underscore,--leading-underscoreβ specifies whether standard symbol should be forced to be prefixed, or not. that's the whole vibe check.--add-stdcall-underscoreβ when dlltool is creating the exports file, prepend an underscore to the names of exported stdcall functions. variable names and non-stdcall function names are not modified. this is useful when creating GNU-compatible import libs for third party DLLs that were built with MS-Windows tools π-k,--kill-atβ@<number>suffixes should be omitted from the names of stdcall functions that will be imported from the DLL. useful when you're making an import library for a DLL that exports stdcall functions but without the usual@<number>symbol name suffix.
careful bestie: this does not change the naming of symbols provided by the import library to programs linked against it β it only changes the entries in the import table (ie the .idata section).
-A,--add-stdcall-aliasβ when dlltool is creating the exports file, add aliases for stdcall symbols without@ <number>in addition to the symbols with@ <number>.-p,--ext-prefix-aliasprefix β makes dlltool create external aliases for all DLL imports using the specified prefix. the aliases are created for both external and import symbols with no leading underscore β¨-x,--no-idata4β when dlltool is creating the exports and library files, omit the".idata4"section. this is for compatibility with certain operating systems.--use-nul-prefixed-import-tablesβ when dlltool is creating the exports and library files, prefix the".idata4"and".idata5"by zero an element. this emulates old gnu import library generation of"dlltool". by default this option is turned off. retro vibes π-c,--no-idata5β when dlltool is creating the exports and library files, omit the".idata5"section. also for compatibility with certain operating systems.-Ifilename,--identifyfilename β tells dlltool to inspect the import library indicated by filename and report, on"stdout", the name(s) of the associated DLL(s). you can do this in addition to any other operations indicated by the other options and arguments. dlltool fails if the import library doesn't exist or isn't actually an import library π see also--identify-strict.--identify-strictβ modifies the behavior of--identify, such that an error is reported if filename is associated with more than one DLL. one DLL only, no polyamory π«Ά-i,--interworkβ dlltool should mark the objects in the library file and exports file that it produces as supporting interworking between ARM and Thumb code.-n,--nodeleteβ makes dlltool preserve the temporary assembler files it used to create the exports file. and if you repeat this option, dlltool will also preserve the temporary object files it uses to create the library file. hoarder mode: activated π-tprefix,--temp-prefixprefix β makes dlltool use prefix when constructing the names of temporary assembler and object files. by default, the temp file prefix is generated from the pid.-v,--verboseβ make dlltool describe what it is doing. narrating its own life, as it should π£-h,--helpβ displays a list of command-line options and then exits.-V,--versionβ displays dlltool's version number and then exits.@file β read command-line options from file. the options that get read are inserted in place of the original@file option. if file does not exist, or cannot be read, then the option is treated literally, and not removed. no cap.
options inside file are separated by whitespace. a whitespace character can be included in an option by surrounding the whole option in either single or double quotes. any character (including a backslash) can be included by prefixing the character to be included with a backslash. and plot twist: the file may itself contain additional @file options β any such options will be processed recursively π
π SEE ALSO
the Info pages for binutils. go read them, they're lowkey iconic π
Β©οΈ COPYRIGHT
Copyright (c) 1991-2026 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".
okay that's the whole page bestie, you made it to the end π this was binutils-2.46.1, dated 2026-09-07, and it's the DLLTOOL(1) manual. go forth and export some symbols responsibly, ily ππ¦β¨
π¦ where this page comes from
- fedora 44: cross-binutils-common 2.46.1-1.fc44 Β· GPL-3.0-or-later AND (GPL-3.0-or-later WITH Bison-exception-2.2) AND (LGPL-2.0-or-later WITH GCC-exception-2.0) AND BSD-3-Clause AND GFDL-1.3-or-later AND GPL-2.0-or-later AND LGPL-2.1-or-later AND LGPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms