In which CPP file the dynamic library or static library is used, the macro in the library is added to the preprocessing command for the project where the H/cpp file resides.
If there is a library project add, its header file is as follows
#ifndef _add_h #define _add_h#if defined (_WIN32) | | Defined (__mingw32__)# if defined (add_exports) # define Add_export __declspec ( dllexport) # | | ! defined (add_use_static_lib) # define Add_export __declspec (dllimport) # else# define add_export# int Add (intint b); #endif
When you compile a dynamic library on VS, you need to add add_exports to the preprocessor directives in the Add Project.
Another test project: if it is going to use the ADD function in a dynamic library, it needs to use the Add_use_dll_import preprocessing directive in its engineering.
How to use macros from a C + + dynamic library with a static library