LinuxCommandLibrary

dlltool

Create Windows DLL import libraries

SYNOPSIS

dlltool [option]... [file]...

PARAMETERS

--add-stdcall-alias
    Export stdcall aliases with mangled names

--as[=AS]
    Assembler to use (default: as)

--as-flags=FLAGS
    Flags to pass to assembler

--compat-implib
    Create backward-compatible import library

--data
    Include data symbols in exports

--def FILE | --input-def FILE
    Specify .def file input

--deterministic
    Omit timestamps for reproducible builds

--dllname=NAME
    Name of DLL for implib

--dll-entry=NAME
    DLL entry point name

--dt-dllname=NAME
    DLL name for delay import lib

--dt-dir=DIRECTORY
    Output directory for delay implib

--dt-implib=NAME
    Output delay import library name

--excludesyms=SYM,...
    Symbols to exclude from exports

--export-all-symbols
    Export all symbols

--extdll
    Treat input files as external DLLs

--extract-demangle
    Extract demangled names from objects

--filename
    Include filename in symbol info

--filter-action=FILTER
    Action for symbols matching filter

--filter-archive=FILTER
    Archive name filter pattern

--format=FORMAT
    Object format (default: elf)

--function-sections
    Place each function in own section

--identify
    Identify input file formats

--implib=NAME
    Output import library name

--kill-at
    Kill @ ordinals in symbol names

--machine=MACHINE
    Target machine type (i386, x86-64, etc.)

--multiply-defined=MULT
    Handling for multiply-defined symbols (error, discard, first, last)

--nodelete
    Keep temporary files

--no-export-all-symbols
    Do not export all symbols

--output-def=FILE
    Output .def file

--output-delaylib=FILE
    Output delay import library

--output-exp=FILE
    Output export file

--output-implib=FILE
    Output import library

--output-lib=FILE
    Output import library (legacy)

--quiet
    Suppress warnings

--renamed-symbol=OLD=NEW
    Rename symbol OLD to NEW

--stack-alignment=NUMBER
    Stack alignment (default 4)

--strip-symbol=SYM
    Strip specified symbol

DESCRIPTION

dlltool is a utility from the GNU Binutils package, primarily used to create files necessary for linking with Microsoft Windows Dynamic Link Libraries (DLLs). It is especially valuable in cross-compilation setups, such as MinGW-w64 on Linux, where developers build Windows executables and libraries from Unix-like systems.

The tool processes definition files (.def), object files, or DLLs to generate import libraries (.a or .lib files), export files (.exp), delay-import libraries, and updated .def files. It handles symbol exports, ordinals, aliases, and private imports, supporting features like stdcall conventions and multiply-defined symbols.

Common workflows include generating an import library from a .def file for static linking, or extracting exports from a DLL to create a .def for rebuilding. It supports various PE/COFF machines (x86, x86-64, ARM) and options for deterministic builds or demangling.

While powerful for Windows development on Linux, it requires a binutils installation configured for PE targets. Usage often pairs with gcc (mingw) and ld for full toolchain support.

CAVEATS

Primarily for PE/COFF (Windows) targets; requires binutils with PE support. Not for native ELF/shared objects. Some options deprecated in favor of ld --out-implib.

COMMON USAGE EXAMPLE

dlltool --dllname foo.dll --def foo.def --output-lib libfoo.a
Generates import library libfoo.a from foo.def.

FROM DLL TO DEF

dlltool -z -m i386 -k --dllname foo.dll foo.dll
Creates foo.def from existing DLL (extract symbols).

HISTORY

Part of GNU Binutils since early 2000s for PE/COFF support; evolved with MinGW/MSYS2 ecosystems. Key enhancements in binutils 2.26+ for delay imports and determinism.

SEE ALSO

ld(1), objdump(1), nm(1), gcc(1)

Copied to clipboard