DLLTOOL(1)

πŸ“¦
version 2.46.1 Β· 5 versions
, in fedora 44

πŸ’– 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:

  • -d filename, --input-def filename β€” tells dlltool the name of the .def file it should read in and process. that's it, that's the job 🫢
  • -b filename, --base-file filename β€” 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 ✨
  • -e filename, --output-exp filename β€” the name of the export file dlltool should create. slay.
  • -z filename, --output-def filename β€” the name of the .def file dlltool should create. cute.
  • -l filename, --output-lib filename β€” the name of the library file dlltool should create. iconic.
  • -y filename, --output-delaylib filename β€” 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-lib or --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 .def file, or in .drectve sections in the input object files. this is the default behaviour. those .drectve sections are created by dllexport attributes in the source code, iykyk.
  • --exclude-symbols list β€” 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-symbols is used. 🚫
  • --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 if you wanna go ahead and export those special symbols anyway. only meaningful with --export-all-symbols. periodt.
  • -S path, --as path β€” the path, including the filename, of the assembler to use when creating the exports file.
  • -f options, --as-flags options β€” any specific command-line options to pass to the assembler when building the exports file. this works even if you didn't use the -S option. 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.
  • -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 pass this option, then the filename you gave to -e gets used as the name of the DLL. main character energy either way πŸ‘‘
  • -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 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-alias prefix β€” 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.
  • -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 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 πŸ’…
  • -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 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 (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