DLLTOOL(1)

πŸ’… dlltool(1) β€” from the GNU Development Tools collection ✨

okay bestie, buckle up β€” this is the manual for dlltool, and it's a whole journey. Part one, comin' at you πŸ’–


✨ 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 🌸

okay so dlltool reads its inputs β€” and those inputs can come from the -d and -b options, plus any object files you hand it on the command line. It chews through all of that, and then:

  • if you gave it -e, it makes an exports file πŸ”₯
  • if you gave it -l, it makes a library file πŸ’–
  • if you gave it -z, it makes a def file ✨

And the iconic part? Any or all of -e, -l, and -z can show up in the same single invocation of dlltool. Not me giving you three files in one go, slay πŸ‘‘

πŸŽ€ the three files situation πŸŽ€

When you're creating a DLL β€” alongside the source for that DLL β€” you need three other files. And dlltool is literally here to help you make them. Let's do a vibe check on each one, bestie 🫢

1️⃣ the .def file

The first file is a .def file. It spells out 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 if that's your thing β€” or you can make dlltool do it for you with the -z option. In that case, dlltool scans the object files you listed on its command line, looking for functions that have been specially marked as being exported, and puts entries for them into the .def file it creates πŸ’…

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

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

int my_func (void) { ... }

periodt. That's the whole ritual πŸ•―οΈ

2️⃣ the exports file

The second file you need for DLL creation is an exports file. This one gets linked together with the object files that make up the body of the DLL, and it handles the interface between your 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 πŸ”₯

3️⃣ the library file

The third file is the library file that programs will link with in order to access the functions in the DLL β€” an `import library` πŸŽ€. You make this one by giving the -l option to dlltool while it's creating or reading in a .def file. Cute, useful, essential. We love a triple threat ✨

🌈 the -y delay-import moment 🌈

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.

But heads up bestie: 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. That chain is doing a lot, and it needs all its pieces 🧚

πŸ‘‘ how dlltool actually builds stuff πŸ‘‘

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. So:

  • -S on the command line lets you specify the path to the assembler that dlltool will use πŸ› οΈ
  • -f lets you pass specific flags through to that assembler 🚩
  • -n stops dlltool from deleting those temporary assembler files once it's done πŸ—‘οΈβŒ
  • and if you specify -n twice, that also stops dlltool from deleting the temporary object files it used to build the library πŸ’€ (yes, twice. it's giving loyalty card.)

πŸ’œ a whole example, look at her go πŸ’œ

Here's an example of creating a DLL from a source file dll.c β€” and also creating a program (out of 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

ate and left no crumbs πŸ“

πŸ” one more trick: the identify era πŸ”

dlltool can also be used to query an existing import library to figure out the name of the DLL it's associated with πŸ‘€. See the description of the -I or --identify option for that one β€” iykyk πŸ’«


and that's only the beginning of the glow-up, bestie β€” the OPTIONS are next and there is a lot to be obsessed with πŸ’…βœ¨

✨ OPTIONS ✨

okay bestie, here's the whole menu of flags πŸ’… every single one, no skips, we're thorough in this house.

  • -d filename, --input-def filename β€” names the .def file that dlltool should read in and process. yes, we're reading a def file, that's the whole vibe.
  • -b filename, --base-file filename β€” names a base file to read in and process. whatever's inside it gets added to the relocation section of the exports file that dlltool generates. cute, it's contributing 🫢
  • -e filename, --output-exp filename β€” names the export file dlltool should create. this is the output, bestie, this is the moment ✨
  • -z filename, --output-def filename β€” names the .def file dlltool should create.
  • -l filename, --output-lib filename β€” names the library file dlltool should create.
  • -y filename, --output-delaylib filename β€” names the delay-import library file dlltool should create. delayed but not forgotten πŸ’…
  • --deterministic-libraries, --non-deterministic-libraries β€” when you're making output libraries with either --output-lib or --output-delaylib, you get to pick: use zero for any timestamps, user ids and group ids created (--deterministic-libraries), or use the actual real-life timestamps, user ids and group ids (--non-deterministic-libraries). pick your fighter πŸŽ€
  • --export-all-symbols β€” treat every global and weak defined symbol found in the input object files as a symbol to export. there's a small list of symbols that do not get exported by default; peep the --no-default-excludes option for that tea. you can also add to the do-not-export list using --exclude-symbols.
  • --no-export-all-symbols β€” only export symbols that are explicitly listed in an input .def file or in .drectve sections of the input object files. this is the default behaviour, fyi. those .drectve sections get created by dllexport attributes in the source code. slay.
  • --exclude-symbols list β€” do not export the symbols in list. it's a list of symbol names separated by comma or colon characters. the symbol names should not have a leading underscore. only meaningful when --export-all-symbols is in play.
  • --no-default-excludes β€” when --export-all-symbols is used, by default it avoids exporting certain special symbols. the current list of symbols it avoids is DllMain@12, DllEntryPoint@0, impure_ptr. you can use --no-default-excludes to go ahead and export those special symbols anyway. only meaningful when --export-all-symbols is used, obviously.
  • -S path, --as path β€” specifies the path, filename included, of the assembler to use when creating the exports file.
  • -f options, --as-flags options β€” any specific command-line options you want to pass to the assembler while building the exports file. this works even if -S isn't used. heads up though: this option only takes one argument, and if it shows up more than once on the command line, the later ones override the earlier ones. so if you need to pass multiple options to the assembler, wrap them in double quotes. periodt.
  • -D name, --dll-name name β€” the name to store in the .def file as the DLL's name, for when the -e option is used. if you don't use this option, then whatever filename you gave to -e gets used as the DLL 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. it's normally only useful when creating DLLs for an ARM processor, where the contents of the DLL are actually encoded using Thumb instructions.
  • -a, --add-indirect β€” tells dlltool that when it's creating the exports file, it should add a section allowing the exported functions to be referenced without using the import library. whatever the hell that means! 😭 (that's the manual's words, not mine, i'm just the messenger)
  • -U, --add-underscore β€” tells dlltool that when it's creating the exports file, it should prepend an underscore to the names of all exported symbols. _ bestie, we're prefixing πŸ’…
  • --no-leading-underscore, --leading-underscore β€” decides whether standard symbols get forced to be prefixed. or not. your call, queen πŸ‘‘
  • --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 you're making GNU-compatible import libs for third party DLLs that were built with MS-Windows tools.
  • -k, --kill-at β€” makes @<number> suffixes get omitted from the names of stdcall functions that will be imported from the DLL. useful when making an import library for a DLL that exports stdcall functions but without the usual @<number> symbol name suffix.

just so we're clear: this does not change the naming of symbols the import library provides to programs linked against it. it only changes the entries in the import table (ie the .idata section). don't get it twisted πŸ’€

  • -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>. both. we contain multitudes 🌈
  • -p, --ext-prefix-alias prefix β€” makes dlltool create external aliases for all DLL imports with the specified prefix. the aliases get 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. some of them are just built different, i guess πŸ¦‹
  • --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 the old gnu import library generation of "dlltool". by default this option is turned off.
  • -c, --no-idata5 β€” when dlltool is creating the exports and library files, omit the ".idata5" section. again, for compatibility with certain operating systems.
  • -I filename, --identify filename β€” 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 how --identify behaves, so that an error gets reported if filename is associated with more than one DLL. one DLL only, no polyamory today sorry 😀
  • -i, --interwork β€” tells dlltool to mark the objects in the library file and exports file it produces as supporting interworking between ARM and Thumb code. bridges built, connections made 🀝
  • -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. hoarder mode, but make it intentional πŸŽ€
  • -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. narration on, main character energy πŸ‘‘
  • -h, --help β€” displays a list of command-line options and then exits. your little guided tour ✨
  • -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 doesn't exist, or can't be read, then the option is treated literally, and not removed.

options inside 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 the character to be included with a backslash. and yes, file may itself contain additional @file options β€” those get processed recursively. it's giving inception πŸŒ€


πŸ¦‹ SEE ALSO πŸ¦‹

the Info pages for binutils. that's the whole guest list, bestie.


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 a wrap on DLLTOOL(1), bestie πŸ’– this page came from binutils-2.47, dated 2026-09-12, and we ate every single line of it. no crumbs. periodt. πŸŽ€βœ¨

πŸ“¦ where this page comes from