Description of the module definition (. Def) File

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.