A module-definition or DEF file (*.def) is a text file containing one or more module statements that describe various attributes of a DLL. If you are not using the __declspec(dllexport) keyword to export the DLL's functions, the DLL requires a DEF file.
The /DEF linker option passes a module-definition file (.def) to the linker. Only one .def file can be specified to LINK. For details about .def files, see Module-definition files. To specify a .def file from within the development environment, add it to the project along with your other source files and then specify the file in the project's Property Pages dialog.
Create a module definition (.def) file and use the .def file when building the DLL. Use this approach if you want to export functions from your DLL by ordinal rather than by name. Use the keyword __declspec(dllexport) in the function's definition. When exporting functions with either method, make sure to use the __stdcall calling convention.
Module-definition (.def) files provide the linker with information about exports, attributes, and other information about the program to be linked. A .def file is most useful when building a DLL. Because there are MSVC Linker Options that can be used instead of module-definition statements, .def files are generally not necessary.
A module-definition (.def) file is a text file containing one or more module statements that describe various attributes of a DLL. If you do not use __declspec(dllimport) or __declspec(dllexport) to export a DLL's functions, the DLL requires a .def file. You can use .def files to import into an application or to export from a DLL.
Learn more about: Importing Using DEF Files Using CONSTANT is more risky because if you forget to use the extra level of indirection, you could potentially access the import address table's pointer to the variable — not the variable itself. This type of problem can often manifest as an access violation because the import address table is currently made read-only by the compiler and linker ...