模块定义 (.Def) 文件Module-Definition (.Def) Files

模块定义 (.def) 文件提供链接器提供有关导出、 属性和要链接的程序有关的其他信息。Module-definition (.def) files provide the linker with information about exports, attributes, and other information about the program to be linked. .Def 文件生成 DLL 时最有用。A .def file is most useful when building a DLL. 由于没有MSVC 链接器选项,可以使用而不是模块定义语句.def 文件通常是不必要。Because there are MSVC Linker Options that can be used instead of module-definition statements, .def files are generally not necessary. 此外可以使用__declspec (dllexport)作为一种方法来指定导出的函数。You can also use __declspec(dllexport) as a way to specify exported functions.

可以在链接器阶段调用.def 文件/DEF (指定模块定义文件)链接器选项。You can invoke a .def file during the linker phase with the /DEF (Specify Module-Definition File) linker option.

如果要构建具有没有导出的.exe 文件,使用.def 文件将使输出文件更大和较慢加载速度。If you are building an .exe file that has no exports, using a .def file will make your output file larger and slower loading.

有关示例,请参阅DLL 使用 DEF 文件从导出For an example, see Exporting from a DLL Using DEF Files.

请参阅以下各节,有关详细信息:See the following sections for more information:

请参阅See also

C/C++ 生成参考C/C++ Building Reference
MSVC 链接器选项MSVC Linker Options