DLLTOOL(1)
π NAME π
dlltool β create files needed to build and use DLLs
Okay so this is the dlltool(1) page from GNU Development Tools, bestie β itβs the utility that helps you make the files you need 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 object files you specify on the command line. Then it processes those inputs, and depending on what you asked for:
- if the
-eoption is specified, it creates an exports file - if the
-loption is specified, it creates a library file - if the
-zoption is specified, it creates a def file
Any or all of the -e, -l and -z options can be present in one invocation of dlltool. Periodt. β¨
When youβre creating a DLL, along with the source for the DLL, it is necessary to have three other files. dlltool can help with the creation of these files. π
File one: the .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 create it by hand, or dlltool can create it with the -z option. In that case, dlltool scans the object files specified on its command line looking for those functions that have been specially marked as being exported, and puts entries for them in the .def file it creates. π¦
In order 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. In C, you can do that with the asm() operator:
asm (".section .drectve");
asm (".ascii \"-export:my_func\"");
int my_func (void) { ... }
File two: the exports file. This file is 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βs creating or reading in a .def file. No cap, thatβs the whole job. π
File three: the library file. This is the library file that programs will link with in order to access the functions in the DLL β an import library. You can create it by giving the -l option to dlltool when itβs creating or reading in a .def file. πΈ
If the -y option is specified, dlltool generates a delay-import library that can be used instead of the normal import library to allow a program to 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. π§
dlltool builds the library file by hand, but it builds the exports file by creating temporary files containing assembler statements and then assembling these. The -S command-line option can be used to specify the path to the assembler that dlltool will use, and the -f option can be used to pass specific flags to that assembler. The -n can be used to prevent dlltool from deleting these temporary assembler files when it is done, and if -n is specified twice, then this will prevent dlltool from deleting the temporary object files it used to build the library. π
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 to which it is associated. See the description of the -I or --identify option. That oneβs lowkey iconic. π
β¨ OPTIONS β¨
Okay bestie, this is the part you actually came for β every single flag, what it does, and zero gatekeeping. Let's go π
-d filename,--input-def filenameβ tells dlltool which.deffile to read in and process. That's the input, the inspo, the blueprint π-b filename,--base-file filenameβ points at a base file to read in and process. Whatever's in there gets added into the relocation section of the exports file dlltool generates. Like a little care package for the relocations π«Ά-e filename,--output-exp filenameβ names the export file dlltool should create. This is the output, bestie β¨-z filename,--output-def filenameβ names the.deffile dlltool should create. Yes, it reads defs and writes defs, she contains multitudes π¦-l filename,--output-lib filenameβ names the library file dlltool should create. The main character of your linking era π-y filename,--output-delaylib filenameβ names the delay-import library file dlltool should create. Fashionably late import lib, iconic behaviour β--deterministic-libraries,--non-deterministic-librariesβ when you're making output libraries via either--output-libor--output-delaylib, this picks whether timestamps, user ids and group ids get written as the value zero (--deterministic-libraries) or as their actual real values (--non-deterministic-libraries). Reproducible vibes vs. honest vibes, your call π--export-all-symbolsβ treats every global and weak defined symbol in the input object files as a symbol to export. There's a small list of symbols that aren't exported by default β peep the--no-default-excludesoption for that tea. If you want to add even more names to the do-not-export list, use--exclude-symbols. Basically: everyone gets an invite to the party π--no-export-all-symbolsβ only exports symbols that are explicitly listed in an input.deffile or in.drectvesections of the input object files. This is the default behaviour, ngl. Those.drectvesections come fromdllexportattributes in the source code. Strict guest list energy πͺ--exclude-symbols listβ do NOT export the symbols in list. It's a list of symbol names separated by comma or colon characters. Heads up: the symbol names should not contain a leading underscore. This one only means anything when--export-all-symbolsis being used. Blocked π--no-default-excludesβ when--export-all-symbolsis in play, dlltool by default dodges exporting certain special symbols. The current avoid-list isDllMain@12,DllEntryPoint@0,impure_ptr. This option says "nah, export those too". Again, only meaningful when--export-all-symbolsis used π«£-S path,--as pathβ specifies the path, filename included, of the assembler to use when creating the exports file. Full path, bestie, don't be shy π§-f options,--as-flags optionsβ any specific command-line options you want passed to the assembler while it's building the exports file. It works even if you didn't use-S. Important: 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. One slot only, no exceptions π€-D name,--dll-name nameβ sets the name stored in the.deffile as the DLL's name when the-eoption is used. If you don't pass this, the filename you gave to-ebecomes the DLL name. Fallback queen behaviour π-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 overrides it. Normally only useful when making DLLs for an ARM processor, when the contents of the DLL are actually encoded using Thumb instructions. Machine type matters, 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 genuinely what the page says, bestie β we report, we don't explain π)-U,--add-underscoreβ when dlltool is creating the exports file, prepend an underscore to the names of all exported symbols. Little underscore, big difference π--no-leading-underscore,--leading-underscoreβ says whether the standard symbol should be forced to be prefixed or not. Pick your side π--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 one's handy when creating GNU-compatible import libs for third-party DLLs built with MS-Windows tools. Selective underscore application, we love precision β¨-k,--kill-atβ says@<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.
Heads up though: 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). Naming stays, table changes, keep that straight π§
-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 versions, no FOMO π«Ά-p,--ext-prefix-alias prefixβ causes dlltool to 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. Prefix era π-x,--no-idata4β when dlltool is creating the exports and library files, omit the.idata4section. This is for compatibility with certain operating systems. Old-school compat, respect it π°οΈ--use-nul-prefixed-import-tablesβ when dlltool is creating the exports and library files, prefix the.idata4and.idata5by zero an element. This emulates old gnu import library generation of "dlltool". By default this option is turned off. Nostalgia mode: disabled by default π§-c,--no-idata5β when dlltool is creating the exports and library files, omit the.idata5section. Also for compatibility with certain operating systems. Sibling of-x, obviously π-I filename,--identify filenameβ says dlltool should inspect the import library named by filename and report the name(s) of the associated DLL(s) onstdout. This can happen in addition to any other operations the other options and arguments call for. dlltool fails if the import library doesn't exist or isn't actually an import library. Also see--identify-strict. Detective mode π--identify-strictβ modifies the behaviour of--identifyso that an error gets reported if filename is associated with more than one DLL. One DLL only, we're monogamous π-i,--interworkβ says dlltool should mark the objects in the library file and exports file it produces as supporting interworking between ARM and Thumb code. Cross-architecture friendship π€-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. Name your temp files, bestie π·οΈ-v,--verboseβ makes dlltool describe what it's doing. She narrates her own life β¨-h,--helpβ displays a list of command-line options, then exits. The classic π-V,--versionβ displays dlltool's version number, then exits. Identity check π@fileβ read command-line options from file. The options that get read are inserted in place of the original@fileoption. If file doesn't exist, or can't be read, then the option is treated literally and not removed. Careful with that one π
Options inside file are separated by whitespace. A whitespace character can be included inside an option by wrapping the whole option in either single or double quotes. Any character (including a backslash) can be included by prefixing that character with a backslash. And the file may itself contain additional @file options β those get processed recursively. It's @file-ception, no cap π
π SEE ALSO π
The Info pages for binutils. That's the plug, go read them π
π 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". Legal bestie has entered the chat π«Ά
okay that's the whole page, you're officially dlltool-literate, I'm so proud of you ππ this one's from binutils-2.47, dated 2026-08-26 β go forth and generate some libraries, bestie, slay πβ¨
π¦ where this page comes from
- arch rolling: loongarch64-linux-gnu-binutils 2.47-1 Β· GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-2.0-or-later AND LGPL-3.0-or-later AND GFDL-1.3-or-later AND FSFAP
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms