Glossary in msdn
The module definition (. Def) file provides the linker with information about the export, attributes, and other aspects of the linked program. When a DLL is generated, the. Def file is the most useful. The module definition statement can be replaced
Linker OptionsThe. Def file is usually not required. You can also set
_ Declspec (dllexport)Used to specify the export function. Available in the linker stage
/DEF (specified module definition file)The linker option calls the. Def file.
If the generated. EXE file is not exported, using the. Def file will increase the output file and reduce the loading speed.
General explanation:
In VC ++, you can generate a DLL without using the. Def file. You only need to add _ declspec (dllexport) before the Function Definition of VC ++. However, using _ declspec (dllexport) is different from using a. Def file. If the DLL is provided to VC ++ users, you only need to provide the. Lib generated during DLL compilation to users. It can easily call your DLL. However, if your DLL is for other programs such as VB, Delphi, and. net
This can cause a small amount of trouble. Because VC ++ converts the name of a function declared by _ declspec (dllexport), the following functions are provided:
_ Declspec (dllexport) int _ stdcall iswinnt ()
It will be converted to iswinnt @ 0, so that you must declare in VB as follows:
Declare function iswinnt lib "My. dll" alias "iswinnt @ 0" () as long
The number following @ may vary depending on the parameter type. This is obviously inconvenient. If you want to avoid this conversion, you must use the. Def file method.
The number after exports can be left blank, and the system will automatically allocate a number. For VB, Pb, and Delphi users, the method of calling by name is usually used. This number does not matter, but is used. for the VC program linked to Lib, it is not called by name, but by this number, so it is best to give.
Example: Use vc6.0 to create a DLL without using the. Def file. Write it in the header file as follows:
# Ifndef lib_h
# Define lib_h
Extern "C" int _ declspec (dllexport) add (int x, int y );
# Endif
If it is a. Def file, you can do this.
Library "xxx_dll"
Exports
Add privat