.DEF

DEF File

Module-Definition File
Ask a question
QUICK ANSWER

A DEF file is a plain-text linker directive file - most commonly an EXPORTS list that tells the Windows linker which functions a DLL should expose. Open it in any text editor such as VS Code or Notepad++. It is a build input passed to the linker with /DEF:name.def, not a program you run.

Developer: Microsoft (Windows toolchain; also used by MinGW/GCC, Watcom, Digital Mars) Category: Developer Files MIME: text/plain
OPENS ON Windows macOS Linux
Related: .DO · .MD · .HEX · .XSD

On this page

19k+ extensions indexed
Last reviewed Jul 13, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

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: LOW

A 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
FULL NAMEModule-Definition Fileaka Module Definition File, DEF file
DEVELOPERMicrosoft (Windows toolchain; also used by MinGW/GCC, Watcom, Digital Mars)since Windows / OS/2 development, late 1980s-1990s (16-bit, then Win32)
MIME TYPEtext/plain
TYPEPlain-text linker directive file (statements: LIBRARY, EXPORTS, IMPORTS...)
This extension is also used by…
  • 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

Windows4 apps
Windows Notepad Built-in Open with > Notepad for a quick read of a small .def; lacks syntax help.
Notepad Open-source Right-click > Edit with Notepad++ to view/edit the linker directives with line numbers.
Visual Studio Code Free Open the .def to read/edit the EXPORTS list as plain text. Best free general choice.
Visual Studio (MSVC) Freemium Add the .def to a project and pass it via Linker > Input > Module Definition File (/DEF). Visual Studio also opens it as text for editing.
macOS1 app
Visual Studio Code Free Open to read/edit the .def text (relevant when cross-compiling Windows DLLs with LLVM/MinGW).
Linux2 apps
nano / vim Open-source Edit in the terminal when cross-building Windows DLLs (MinGW-w64/LLVM consume .def via -Wl,--def or /DEF).
Visual Studio Code Free Open the .def to edit exports for a cross-compiled DLL.

Technical details

deep spec
Format typePlain-text linker directive file
MIME typetext/plain
Character encodingASCII / 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 sizeUnder 1 KB to a few KB (one exported symbol per line)
Core statement: LIBRARY / NAMEDeclares the module name embedded in the DLL's internal header
Core statement: EXPORTSLists each symbol to expose, with optional ordinal (@N), NONAME, and DATA flags
Additional statementsIMPORTS, SECTIONS (set section attributes), HEAPSIZE, STACKSIZE
Linker switch (MSVC)/DEF:filename.def passed to link.exe at build time
Supporting toolchainsMSVC link.exe, MinGW/GCC ld, LLVM lld-link, Watcom linker, Digital Mars linker
Output artifactsControls the export table of a .dll and the import library (.lib) generated alongside it
Associated operating systemsWindows (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 keywordsCODE and DATA segment-attribute statements present in 16-bit Windows/OS/2 DEF files; obsolete under Win32
Compression and encryptionNone - always stored as uncompressed, unencrypted plain text
ReleasedWindows / OS/2 development, late 1980s-1990s (16-bit, then Win32)
Latest versionSame statement syntax used by the current MSVC linker (link.exe) and LLVM lld-link
Specificationlearn.microsoft.com

DEF conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with DEF files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about DEF files.

Frequently asked questions

What is a .def file in programming?
A module-definition file: a plain-text list of linker directives - chiefly an EXPORTS section naming the functions a DLL should expose. You pass it to the linker (link /DEF:name.def) when building a Windows DLL or EXE.
How do I open a .def file?
It's plain text - open it in VS Code, Notepad++, or the editor inside Visual Studio. To use it in a build, add it to your project's linker Module-Definition File setting (/DEF).
Do I still need a .def file if I use __declspec(dllexport)?
Often not - source-level export attributes cover most cases. But .def is still useful for stable export ordinals, exporting undecorated C names, or toolchains/legacy projects that expect it.
How do I create a .lib from a .def?
Use the MSVC LIB tool: lib /DEF:name.def /OUT:name.lib /MACHINE:X64 (or MinGW's dlltool). This builds an import library so other code can link against the DLL the .def describes.
Why does my linker report missing exports?
Often the symbol isn't listed in the .def's EXPORTS section, the name is decorated differently than expected, or the ordinal changed. Check the EXPORTS list matches the actual function names and is passed to the linker.
My .def file isn't a linker file - what else uses .def?
Several unrelated programs reuse .def for their own 'definition' data - game map definitions (e.g. Tibia), database/GIS schema (SmartWare, ArcView), or Modula-2/Oberon module interfaces. Those are different formats sharing the extension.

References

1Microsoft Learn - Module-Definition (.def) Fileslearn.microsoft.com
2Microsoft Learn - EXPORTS sectionlearn.microsoft.com

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.CRDOWNLOADChrome Partial Download File
3.MDMarkdown Document
4.BINCD/DVD Disc Image (BIN/CUE)
5.NOMEDIAAndroid No-Media Marker File
6.PARTPartial Download File
7.RPMSGRestricted Permission Message
8.EXEWindows Executable (Portable Executable)
9.AVIFAV1 Image File Format (AVIF)
10.DBSQLite Database File

Related extensions

.DOStata Do-File
.MDMarkdown Document
.HEXIntel HEX File
.XSDXML Schema Definition
.MAPSource Map (JavaScript / CSS)
.CONFIGConfiguration File

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z