DLLTOOL(1)

πŸ“¦
version 2.47 Β· 2 versions
, in ubuntu stonking

πŸ’– DLLTOOL(1) β€” GNU Development Tools πŸ’–

okay bestie, welcome to dlltool, straight outta the GNU Development Tools manual, section 1 ✨ this is the girlie that builds the files you need to make and use DLLs, and she is lowkey a whole infrastructure queen πŸ‘‘


✨ 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 ...]

like, look at her. that's a lot of options and every single one of them is iconic πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so dlltool reads its inputs, okay? those inputs can come from the -d and -b options, plus any object files you drop on the command line 🌈 then it processes all of that, and:

  • if you specified -e, it creates an exports file ✨
  • if you specified -l, it creates a library file πŸ“š
  • if you specified -z, it creates a def file πŸ“

and here's the slay part: any or all of the -e, -l and -z options can be present in one single invocation of dlltool. one girl, three jobs, no complaints. πŸ‘‘


πŸ’œ the three files situation

when you're creating a DLL, alongside the source for the DLL itself, you need three other files. dlltool can help with the creation of these files, because she's helpful like that 🫢

file number one is a .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 absolutely write it by hand if that's your vibe, or you can let dlltool create it for you using the -z option. when you do that, dlltool scans the object files you listed on its command line, looking for the functions that have been specially marked as being exported, and then puts entries for them in the .def file it creates. like a little detective with a clipboard πŸ•΅οΈβ€β™€οΈ

so how do you 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. and you can do that in C by using the asm() operator:

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

                 int my_func (void) { ... }
yes bestie, that's backslash-escaped double quotes inside the string. it's giving "and I oop" but it's correct, don't touch it πŸ™ˆ

file number two needed for DLL creation is an 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 can create it by giving the -e option to dlltool when it is creating or reading in a .def file.

file number three needed for DLL creation is the library file that programs will link with in order to access the functions in the DLL β€” aka the import library πŸ’–. you can create this one by giving the -l option to dlltool when it is creating or reading in a .def file.


✨ the delay-import library moment ✨

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 ⏰ (fashionably late, honestly, but make it functional).

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. chain of command, no cap 🫑


πŸŽ€ how she actually builds stuff

dlltool builds the library file by hand ✍️ but she builds the exports file by creating temporary files containing assembler statements and then assembling those. so:

  • the -S command-line option can be used to specify the path to the assembler that dlltool will use πŸ”§
  • the -f option can be used to pass specific flags to that assembler 🏳️
  • the -n option can be used to stop dlltool from deleting these temporary assembler files when it is done πŸ—‘οΈ
  • and if -n is specified twice, then that will also stop dlltool from deleting the temporary object files it used to build the library πŸ‘€ (double -n = double the hoarding, respect)

🌈 example time 🌈

here is 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

look at her go. four lines. a whole DLL and a whole program. ate and left no crumbs πŸ”₯


🧚 one more little trick

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 for the deets β€” she knows things and she tells you, iykyk πŸ“

✨ OPTIONS ✨

okay bestie, here's the whole menu of command-line flags and what they actually mean. buckle up, there's a lot of them and they're all lowkey important πŸ’…


  • -d filename, --input-def filename β€” names the .def file that dlltool should read in and process. feed it the def file, it does the thing 🫢
  • -b filename, --base-file filename β€” names a base file for dlltool to read in and process. its contents get added into the relocation section of the exports file that dlltool generates. so like, extra relocation data, slotted right in ✨
  • -e filename, --output-exp filename β€” names the export file dlltool is gonna create for you.
  • -z filename, --output-def filename β€” names the .def file dlltool is gonna create.
  • -l filename, --output-lib filename β€” names the library file dlltool is gonna create.
  • -y filename, --output-delaylib filename β€” names the delay-import library file dlltool is gonna create. it's giving "library but fashionably late" πŸ’…
  • --deterministic-libraries, --non-deterministic-libraries β€” when you're making output libraries in response to either the --output-lib or --output-delaylib options, this decides what goes in the timestamps, user ids and group ids: either all zeros (--deterministic-libraries) or the actual real 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 be exported. yes, ALL of them, main character energy πŸ‘‘. there is a small list of symbols that are not exported by default though β€” peep the --no-default-excludes option for that. and you can add 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 of the input object files. this is the default behaviour, no cap. those .drectve sections get created by dllexport attributes in the source code.
  • --exclude-symbols list β€” do NOT export the symbols in list. list is a bunch of symbol names separated by commas or colons. heads up: the symbol names should not have a leading underscore. this only does anything meaningful when --export-all-symbols is in play.
  • --no-default-excludes β€” when --export-all-symbols is used, by default dlltool avoids exporting certain special symbols. the current list of symbols it avoids is DllMain@12, DllEntryPoint@0, impure_ptr. use --no-default-excludes to go ahead and export those special little guys anyway. only meaningful when --export-all-symbols is used 🫢
  • -S path, --as path β€” specifies the path, filename included, of the assembler used to create the exports file.
  • -f options, --as-flags options β€” specifies any specific command-line options to pass to the assembler while building the exports file. works even if -S isn't used, iconic. this option only takes one argument, so 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. fr fr, one arg only.
  • -D name, --dll-name name β€” specifies the name stored in the .def file as the name of the DLL, used when the -e option is used. if this option isn't there, then whatever filename you gave to -e becomes the DLL's name. periodt.
  • -m machine, -machine machine β€” specifies 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 really useful when you're creating DLLs for an ARM processor, where the DLL contents are actually encoded using Thumb instructions.
  • -a, --add-indirect β€” says that when dlltool is creating the exports file, it should add a section letting the exported functions be referenced without using the import library. whatever the hell that means! 😭
  • -U, --add-underscore β€” says that when dlltool is creating 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 is creating 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, leave them alone πŸ™ˆ. this one's useful when you're 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'll be imported from the DLL. useful when you're creating an import library for a DLL that exports stdcall functions but without the usual @<number> symbol name suffix. important: this does not change the naming of the symbols the import library hands to programs linked against it β€” only the entries in the import table (ie the .idata section). not me stressing the difference, but like, it matters πŸ”₯
  • -A, --add-stdcall-alias β€” says that when dlltool is creating the exports file, it should add aliases for stdcall symbols without @ <number> in addition to the symbols with @ <number>. double the symbols, double the slay πŸ’…
  • -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 β€” says that when dlltool is creating 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 is creating the exports and library files, it should 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 β€” says that when dlltool is creating the exports and library files, it should omit the .idata5 section. also 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). this can be done 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 behaviour of --identify, such 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 that it produces as supporting interworking between ARM and Thumb code. ARM girlies, this one's for you 🧚
  • -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. keep those leftovers bestie πŸ“
  • -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. it's narrating its own life, respect πŸ™Œ
  • -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 doesn't exist, or can't be read, then the option is treated literally and is 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 you want with a backslash. and plot twist β€” the file can itself contain additional @file options, and any of those get processed recursively. it's files all the way down πŸ”₯

🌸 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!! this is from binutils-2.47, dated 2026-09-19, and it's the DLLTOOL(1) man page 🫢✨ go build something iconic with it, ily πŸ’–

πŸ“¦ where this page comes from