What is the DEF file format?
.def files are associated with Windows and OS/2 development environments, used alongside C, C++, and other compiled languages.
Files with the .def extension store data in plain text format. .def files are sometimes referred to as module definition files and are used for generating DLL libraries. A .def file stores a special set of linker directives - statements such as LIBRARY, EXPORTS, IMPORTS, SECTIONS, HEAPSIZE, and STACKSIZE - used to define key aspects of a DLL library, including which functions and data symbols are exposed to callers and what ordinal numbers they carry.
The file is passed to the linker at build time using the /DEF:name.def switch (MSVC) or equivalent flags in MinGW/GCC and LLVM lld-link. It is a build input, not a compiled artifact; the resulting binary is a .dll or .exe.
A DLL is a library file that stores executable code and other related data. DLL files are reusable - they can be accessed by multiple applications simultaneously - and loaded dynamically when needed. DLL files are also a means of saving disk space and operational memory due to their dynamic nature. Updating software is also easier due to the fact that DLL files are shared among multiple applications.
Modern C/C++ compilers allow developers to mark exported symbols directly in source code using __declspec(dllexport), largely reducing the need for a separate .def file. However, .def files remain supported by the current MSVC linker (link.exe) and LLVM lld-link, and are still preferred when a stable, explicitly ordered export table is required.
Security & safety
RISK: LOWA module-definition .def is a tiny plain-text build file and is safe to open and read - it cannot execute. The only practical risk is editing it in a real project: changing or removing an EXPORTS entry alters the DLL's public interface and can break callers or change export ordinals, so understand the ABI impact before editing. As with any source file, only trust .def files from project sources you control.
Format details
in a nutshell- Tibia / OTClient map file (.def) - Some game tooling and the Tibia map editor used .def for map/spawn definitions - unrelated to linkers.
- ESRI ArcView / SmartWare data definition - Older database and GIS tools (SmartWare, ArcView, DataFlex) wrote .def schema/definition files of their own.
- AniSprite animation definition / Oberon-2 & Modula-2 DEFINITION module - AniSprite stored sprite-animation definitions in .def; Modula-2/Oberon use .def for a module's public interface.
Programs that open DEF files
Technical details
deep spec| Format type | Plain-text linker directive file |
| MIME type | text/plain |
| Character encoding | ASCII / ANSI; UTF-8 without BOM is typical |
| File signature (magic bytes) | None - identified by keywords such as LIBRARY, EXPORTS, or NAME at the start of lines |
| Typical file size | Under 1 KB to a few KB (one exported symbol per line) |
| Core statement: LIBRARY / NAME | Declares the module name embedded in the DLL's internal header |
| Core statement: EXPORTS | Lists each symbol to expose, with optional ordinal (@N), NONAME, and DATA flags |
| Additional statements | IMPORTS, SECTIONS (set section attributes), HEAPSIZE, STACKSIZE |
| Linker switch (MSVC) | /DEF:filename.def passed to link.exe at build time |
| Supporting toolchains | MSVC link.exe, MinGW/GCC ld, LLVM lld-link, Watcom linker, Digital Mars linker |
| Output artifacts | Controls the export table of a .dll and the import library (.lib) generated alongside it |
| Associated operating systems | Windows (primary); OS/2 (legacy); 16-bit DOS (legacy) |
| Modern alternative | __declspec(dllexport) in source code; .def still preferred for stable export ordinals and toolchain portability |
| Legacy 16-bit keywords | CODE and DATA segment-attribute statements present in 16-bit Windows/OS/2 DEF files; obsolete under Win32 |
| Compression and encryption | None - always stored as uncompressed, unencrypted plain text |
| Released | Windows / OS/2 development, late 1980s-1990s (16-bit, then Win32) |
| Latest version | Same statement syntax used by the current MSVC linker (link.exe) and LLVM lld-link |
| Specification | learn.microsoft.com |
DEF conversions
Community Q&A
asked by usersNo questions yet - be the first to ask about DEF files.