DLLTOOL(1)

πŸ“¦ version 2.47, in arch rolling

πŸ’– NAME πŸ’–

okay so bestie, this is dlltool from the GNU Development Tools manual β€” the icon that creates files needed to build and use DLLs. periodt. 🫢

✨ SYNOPSIS ✨

the whole invocation vibe is this, and every single flag is invited:

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 πŸ¦‹

dlltool reads its inputs, and those inputs can come from the -d and -b options plus any object files you specify 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 🧚

Any or all of -e, -l, and -z can be present in one single invocation of dlltool. no cap. πŸ”₯

When you're creating a DLL, along with the source for the DLL, you need three other files, and dlltool can help you create them. πŸ‘‘

  • first file: the .def file β€” it specifies which functions are exported from the DLL, which functions the DLL imports, and so on. it's a text file, so you can create it by hand, or dlltool can create it for you with the -z option. in that case, dlltool scans the object files specified on its command line looking for functions that have been specially marked as being exported, and it puts entries for them in the .def file it creates. πŸ’–
  • second file: the exports file β€” this one gets linked with the object files that make up the body 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 giving the -e option to dlltool when it's creating or reading in a .def file. 🌈
  • third file: the library file β€” this is the library file that programs will link with in order to access the functions in the DLL (an import library). you create it by giving the -l option to dlltool when it's creating or reading in a .def file. πŸŽ€

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 β€” copy it exactly, bestie:

asm (".section .drectve");
asm (".ascii \"-export:my_func\"");

int my_func (void) { ... }

If you specify the -y option, dlltool generates a delay-import library. that can be used instead of the normal import library to allow a program to 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. 😭

dlltool builds the library file by hand, but it builds the exports file by creating temporary files containing assembler statements and then assembling these. the -S command-line option can be used to specify the path to the assembler that dlltool will use, and the -f option can be used to pass specific flags to that assembler. the -n option can be used to prevent dlltool from deleting these temporary assembler files when it's done, and if -n is specified twice, that prevents dlltool from deleting the temporary object files it used to build the library. πŸ’€

example time β€” 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 to which it is associated. see the description of the -I or --identify option. πŸ‘€

✨ OPTIONS ✨

okay bestie, this is the whole menu of flags β€” every single one, no skips, no cap πŸ’…

  • -d filename, --input-def filename β€” tells dlltool the name of a .def file it should read in and process πŸŽ€
  • -b filename, --base-file filename β€” names a base file to be read in and processed. the contents of this file get added to the relocation section in the exports file that dlltool generates πŸ¦‹
  • -e filename, --output-exp filename β€” the name of the export file dlltool should create 🌸
  • -z filename, --output-def filename β€” the name of the .def file dlltool should create ⭐
  • -l filename, --output-lib filename β€” the name of the library file dlltool should create πŸ’œ
  • -y filename, --output-delaylib filename β€” the name of the delay-import library file dlltool should create ✨
  • --deterministic-libraries, --non-deterministic-libraries β€” when dlltool makes output libraries in response to either the --output-lib or --output-delaylib options, this picks what goes in the metadata: either zero for any timestamps, user ids and group ids created (--deterministic-libraries), or the actual timestamps, user ids and group ids (--non-deterministic-libraries) 🫢
  • --export-all-symbols β€” treat every global and weak defined symbol it finds in the input object files as a symbol to be exported. heads up tho: there's a small list of symbols that are not exported by default β€” peek at --no-default-excludes for that πŸ‘€. and you can add to the list of symbols to not export with --exclude-symbols πŸ’…
  • --no-export-all-symbols β€” only export symbols explicitly listed in an input .def file or in .drectve sections in the input object files. this is the default behaviour btw ✨. those .drectve sections are created by dllexport attributes in the source code πŸŽ€
  • --exclude-symbols list β€” do not export the symbols in list. it's a list of symbol names separated by comma or colon characters, and those names should not contain a leading underscore πŸ™ˆ. this only means anything when --export-all-symbols is in play
  • --no-default-excludes β€” when --export-all-symbols is used, dlltool will by default avoid exporting certain special symbols. the current list of symbols to avoid exporting is DllMain@12, DllEntryPoint@0, impure_ptr πŸ’€. use --no-default-excludes to go ahead and export these special symbols anyway. again: only meaningful when --export-all-symbols is used 🌈
  • -S path, --as path β€” the path, including the filename, of the assembler to be used to create the exports file πŸ› οΈ
  • -f options, --as-flags options β€” any specific command-line options you want passed to the assembler when building the exports file. this works even if -S isn't used 🎯. it only takes one argument, so if it shows up more than once on the command line, later occurrences override earlier occurrences β€” meaning if you need to hand the assembler multiple options, wrap them in double quotes πŸŽ€
  • -D name, --dll-name name β€” the name to be stored in the .def file as the name of the DLL when the -e option is used. if this option isn't there, then the filename you gave to -e gets used as the DLL's name instead πŸ’–
  • -m machine, -machine machine β€” 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 option overrides that πŸ‘‘. normally it's only useful when creating DLLs for an ARM processor, where the contents of the DLL are actually encoded using Thumb instructions πŸ¦‹
  • -a, --add-indirect β€” says that when dlltool creates the exports file it should add a section which allows the exported functions to be referenced without using the import library. whatever the hell that means! 😭 (that's the docs talking, not me)
  • -U, --add-underscore β€” says that when dlltool creates the exports file it should prepend an underscore to the names of all exported symbols πŸ’…
  • --no-leading-underscore, --leading-underscore β€” says whether a standard symbol should be forced to be prefixed, or not πŸ€”
  • --add-stdcall-underscore β€” says that when dlltool creates the exports file it should prepend an underscore to the names of exported stdcall functions. variable names and non-stdcall function names are not modified πŸ™…. super useful when creating GNU-compatible import libs for third-party DLLs that were built with MS-Windows tools πŸͺŸ
  • -k, --kill-at β€” says that @<number> suffixes should be omitted from the names of stdcall functions that will be imported from the DLL. useful when creating an import library for a DLL which exports stdcall functions but without the usual @<number> symbol name suffix ✨
ngl this one's sneaky: it does not change the naming of symbols the import library provides to programs linked against it β€” only the entries in the import table (ie the .idata section) πŸ‘€
  • -A, --add-stdcall-alias β€” says that when dlltool creates the exports file it should add aliases for stdcall symbols without @ <number> in addition to the symbols with @ <number> πŸŽ€
  • -p, --ext-prefix-alias prefix β€” causes dlltool to create external aliases for all DLL imports with the specified prefix. the aliases are created for both external and import symbols with no leading underscore 🌸
  • -x, --no-idata4 β€” says that when dlltool creates the exports and library files it should omit the .idata4 section. this is for compatibility with certain operating systems πŸ–₯️
  • --use-nul-prefixed-import-tables β€” says that when dlltool creates the exports and library files it should 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 ⭐
  • -c, --no-idata5 β€” says that when dlltool creates the exports and library files it should omit the .idata5 section. again, this is for compatibility with certain operating systems πŸ–₯️
  • -I filename, --identify filename β€” says dlltool should 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 the --identify option so that an error gets reported if filename is associated with more than one DLL πŸ™ˆ
  • -i, --interwork β€” says dlltool should mark the objects in the library file and exports file 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 πŸ—‚οΈ. if you repeat this option, dlltool will also preserve the temporary object files it uses to create the library file πŸ‘‘
  • -t prefix, --temp-prefix prefix β€” 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's doing πŸ—£οΈ
  • -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 read get inserted in place of the original @file option ✨. if file doesn't exist, or can't be read, then the option is treated literally and not removed πŸ™ƒ options in file are separated by whitespace. a whitespace character can be included in an option by surrounding the entire option in either single or double quotes πŸŽ€. any character (including a backslash) can be included by prefixing that character with a backslash. and plot twist: the file may itself contain additional @file options β€” any such options get processed recursively πŸŒ€

πŸ” SEE ALSO

the Info pages for binutils πŸ“š


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" πŸ“œ


and that's the whole page, bestie β€” you ate that πŸ“πŸ’… this lil masterpiece is from binutils-2.47, dated 2026-07-30 ✨ go forth and link against things πŸŒˆπŸ‘‘

πŸ“¦ where this page comes from