DLLTOOL(1)

πŸ’– DLLTOOL(1) πŸ’–

okay bestie, pull up a chair, because we're talking about dlltool β€” a lil GNU Development Tools icon that creates the files you need to build and use DLLs. she's from the GNU Development Tools crew and she is, lowkey, the backbone of your whole Windows-ish linking situation. 🫢


✨ NAME ✨

dlltool β€” create files needed to build and use DLLs


πŸŽ€ 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 🌸

so. dlltool reads its inputs, and those inputs can come from the -d and -b options plus any object files you hand her on the command line. she takes all of that in, does her lil processing thing, and then:

  • if you gave her -e, she creates an exports file πŸ’…
  • if you gave her -l, she creates a library file πŸŽ€
  • if you gave her -z, she creates a def file ✨

and the slayest part? any or all of -e, -l and -z can show up in a single invocation of dlltool. one trip, three files, no cap. πŸ‘‘


πŸ¦‹ the three files you need for a DLL πŸ¦‹

when you're creating a DLL, alongside the source for the DLL itself, you need three other files. and dlltool is literally right there to help you make them.

file #1: the .def file 🌸

this one specifies which functions are exported from the DLL, which functions the DLL imports, and so on. it's a text file, so you can write it by hand if you're feeling crafty β€” or you can let dlltool build it for you with the -z option. in that case, dlltool scans the object files you listed on the command line, hunting for the functions that have been specially marked as being exported, and drops entries for them into the .def file she creates.

to mark a function as exported from a DLL, it needs an -export:<name_of_function> entry in the .drectve section of the object file. in C you can do that with the asm() operator, like this:

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

          int my_func (void) { ... }

file #2: 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 make it by giving the -e option to dlltool while she's creating or reading in a .def file.

file #3: the library file πŸŽ€

this is the one programs will link with in order to access the functions inside the DLL β€” aka the import library. you get it by giving the -l option to dlltool while she's creating or reading in a .def file.


πŸ’… the delay-import situation πŸ’…

if you specify the -y option, dlltool generates a delay-import library. you can use it 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 🧚


πŸ”₯ how she actually builds stuff πŸ”₯

here's the tea: dlltool builds the library file by hand, but she builds the exports file by creating temporary files containing assembler statements and then assembling those.

  • the -S command-line option lets you specify the path to the assembler that dlltool will use πŸ› οΈ
  • the -f option lets you pass specific flags to that assembler
  • the -n option stops dlltool from deleting those temporary assembler files when she's done
  • and if -n is specified twice, that also stops her from deleting the temporary object files she used to build the library πŸ’€

🌈 example time 🌈

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

⭐ one more thing ⭐

dlltool may also be used to query an existing import library to figure out the name of the DLL it's associated with. peep the description of the -I or --identify option for that one. πŸ‘€


more parts incoming, bestie β€” do not go anywhere πŸ’–

✨ OPTIONS ✨

okay bestie, here's the whole menu of flags. every single one. grab a snack πŸ“

  • -d filename, --input-def filename β€” names the .def file that dlltool should read in and process. that's the input, the source of truth, the blueprint πŸ’…
  • -b filename, --base-file filename β€” names a base file to read in and process. whatever's inside it gets added to the relocation section in the exports file dlltool generates. lowkey important.
  • -e filename, --output-exp filename β€” names the export file dlltool should create. output vibes only ✨
  • -z filename, --output-def filename β€” names the .def file dlltool should create. yes, it makes one too. main character energy.
  • -l filename, --output-lib filename β€” names the library file dlltool should create. the moment you've all been waiting for πŸŽ€
  • -y filename, --output-delaylib filename β€” names the delay-import library file dlltool should create. fancy.
  • --deterministic-libraries, --non-deterministic-libraries β€” when dlltool is making output libraries because of either --output-lib or --output-delaylib, this picks whether timestamps, user ids and group ids are all set to zero (--deterministic-libraries) or whether you get the actual real timestamps, user ids and group ids (--non-deterministic-libraries). reproducible girlies, rise 🫢
  • --export-all-symbols β€” treat every global and weak defined symbol found in the input object files as a symbol to export. ngl there's a small list of symbols that don't get exported by default β€” that's the --no-default-excludes option's whole deal. and you can add more symbols to the do-not-export list with --exclude-symbols.
  • --no-export-all-symbols β€” only export symbols that are explicitly listed in an input .def file, or in .drectve sections in the input object files. this is the default behaviour, periodt. those .drectve sections get created by dllexport attributes in the source code, iykyk.
  • --exclude-symbols list β€” don't export the symbols in list. it's a list of symbol names separated by comma or colon characters. the symbol names should not contain a leading underscore. this is only meaningful when --export-all-symbols is used. πŸ’€
  • --no-default-excludes β€” when --export-all-symbols is used, dlltool by default avoids 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. only meaningful when --export-all-symbols is used, bestie.
  • -S path, --as path β€” specifies the path, including the filename, of the assembler to use 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 you didn't use the -S option. heads up: this option only takes one argument, and if it shows up more than once on the command line, the later occurrences override the earlier ones. so if you need to pass multiple options to the assembler, wrap them in double quotes. πŸŽ€
  • -D name, --dll-name name β€” the name to store in the .def file as the name of the DLL when the -e option is used. if you don't include this option, then the filename you gave to -e gets used as the DLL's name.
  • -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 only useful when you're creating DLLs for an ARM processor and the DLL's contents are actually encoded using Thumb instructions. πŸ¦‹
  • -a, --add-indirect β€” when dlltool creates the exports file, add a section that allows the exported functions to be referenced without using the import library. "whatever the hell that means!" β€” direct quote, the original manpage said it, not me 😭
  • -U, --add-underscore β€” when dlltool creates the exports file, prepend an underscore to the names of all exported symbols.
  • --no-leading-underscore, --leading-underscore β€” whether a standard symbol should be forced to be prefixed, or not. that's it, that's the whole thing.
  • --add-stdcall-underscore β€” when dlltool creates the exports file, prepend an underscore to the names of exported stdcall functions. variable names and non-stdcall function names are not modified. this one's a lifesaver when you're creating GNU-compatible import libs for third party DLLs that were built with MS-Windows tools. πŸ’œ
  • -k, --kill-at β€” @<number> suffixes get omitted from the names of stdcall functions that will be imported from the DLL. super useful when you're making an import library for a DLL that exports stdcall functions but without the usual @<number> symbol name suffix.

important though: this does not change the naming of symbols provided by the import library to programs linked against it β€” only the entries in the import table (ie the .idata section). so don't @ me.

  • -A, --add-stdcall-alias β€” when dlltool creates the exports file, add aliases for stdcall symbols without @ <number>, in addition to the symbols with @ <number>. both, not either. πŸ’…
  • -p, --ext-prefix-alias prefix β€” makes dlltool create external aliases for all DLL imports using the specified prefix. the aliases get created for both external and import symbols with no leading underscore.
  • -x, --no-idata4 β€” when dlltool creates the exports and library files, omit the ".idata4" section. this is for compatibility with certain operating systems. ✨
  • --use-nul-prefixed-import-tables β€” when dlltool creates 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.
  • -c, --no-idata5 β€” when dlltool creates the exports and library files, omit the ".idata5" section. again, this is for compatibility with certain operating systems. 🧚
  • -I filename, --identify filename β€” dlltool should inspect the import library indicated by filename and report, on "stdout", the name(s) of the associated DLL(s). this can happen in addition to any other operations indicated by the other options and arguments. dlltool fails if the import library does not exist or is not actually an import library. also peep --identify-strict below. πŸ‘‘
  • --identify-strict β€” modifies the behavior of the --identify option so that an error is reported if filename is associated with more than one DLL. no polyamory for your import libs, apparently πŸ’€
  • -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. messy workspace rights πŸ”₯
  • -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 β€” makes dlltool describe what it is doing. narration, bestie πŸŽ™οΈ
  • -h, --help β€” displays a list of command-line options and then exits. classic.
  • -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 does not exist, or cannot be read, then the option will be treated literally, and not removed.

options inside file are separated by whitespace. a whitespace character may be included in an option by surrounding the entire option in either single or double quotes. any character (including a backslash) may 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. it's giving inception πŸŒ€


🌈 SEE ALSO 🌈

the Info pages for binutils. go read 'em, they're right there.


Copyright (c) 1991-2025 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 🫢 this came from binutils-2.45.50, dated 2025-12-09, and it lives at DLLTOOL(1). go build something iconic with it, you've got this πŸ‘‘βœ¨

πŸ“¦ where this page comes from