Two ways to export DLL __declspec(dllexport) and def file

1. Use __declspec(dllexport) to export DLL

1. Modify the output configuration type to DLL

insert image description here

2. Add the function declaration in the header file

__declspec(dllexport) bool cmp(vector<Point> a, vector<Point> b);

Functions can be implemented in .h or .cpp files, depending on personal habits.

3. Right-click the project name and select Generate to generate the DLL

insert image description here

The generated DLL file can be found according to the path.

2. Use the def file to export the DLL

1. Right-click Add -> New Item -> Module Definition File (.def)

insert image description here

Pay attention to check whether the def file is associated with the current project

insert image description here

2. Write the functions to be exported in the file according to the following format

EXPORTS
	cmp

3. Modify the output configuration type to DLL

insert image description here

4. Right-click the project name and select Generate to generate the DLL

insert image description here
The generated DLL file can be found according to the path.

The principle of exporting the dynamic link library and so on are not covered in this article, mainly to make a record for your own viewing.
When creating a project, it is a normal project.

Guess you like

Origin blog.csdn.net/Lianhaiyan_zero/article/details/129669816