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:
-Son the command line lets you specify the path to the assembler thatdlltoolwill use π οΈ-flets you pass specific flags through to that assembler π©-nstopsdlltoolfrom deleting those temporary assembler files once it's done ποΈβ- and if you specify
-ntwice, that also stopsdlltoolfrom 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.
-dfilename,--input-deffilename β names the.deffile that dlltool should read in and process. yes, we're reading a def file, that's the whole vibe.-bfilename,--base-filefilename β 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 π«Ά-efilename,--output-expfilename β names the export file dlltool should create. this is the output, bestie, this is the moment β¨-zfilename,--output-deffilename β names the.deffile dlltool should create.-lfilename,--output-libfilename β names the library file dlltool should create.-yfilename,--output-delaylibfilename β 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-libor--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-excludesoption 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.deffile or in.drectvesections of the input object files. this is the default behaviour, fyi. those.drectvesections get created bydllexportattributes in the source code. slay.--exclude-symbolslist β 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-symbolsis in play.--no-default-excludesβ when--export-all-symbolsis used, by default it avoids exporting certain special symbols. the current list of symbols it avoids isDllMain@12,DllEntryPoint@0,impure_ptr. you can use--no-default-excludesto go ahead and export those special symbols anyway. only meaningful when--export-all-symbolsis used, obviously.-Spath,--aspath β specifies the path, filename included, of the assembler to use when creating the exports file.-foptions,--as-flagsoptions β any specific command-line options you want to pass to the assembler while building the exports file. this works even if-Sisn'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.-Dname,--dll-namename β the name to store in the.deffile as the DLL's name, for when the-eoption is used. if you don't use this option, then whatever filename you gave to-egets used as the DLL name instead.-mmachine,-machinemachine β 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-aliasprefix β 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.-Ifilename,--identifyfilename β 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--identifybehaves, 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 π-tprefix,--temp-prefixprefix β 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 π
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
- ubuntu stonking: binutils-bpf 2.47-6ubuntu1+2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms