i am trying to generate dll file, use its .lib file in another program ,but unfortunately, no .lib file is generated! what should i do?
Try it like this:
extern "C" _declspec (dllexport) int add(int a, int b);
extern "C" _declspec (dllexport) int add(int a, int b)
{
return a + b;
}
You'll need to use __declspec
(two underscores) with dllexport
attribute to export a symbol from a DLL. And on client side you'll need to use __declspec(dllimport)
.
You better put the declaration on header like this:
// YourHeader.H
#ifdef _DLL_EXPORTING // Define this symbol in DLL project setting
#define EXPORT_IMPORT __declspec(dllexport)
#else
#define EXPORT_IMPORT __declspec(dllimport)
#endif
EXPORT_IMPORT int add(int,int);
Let the client use this header directly without worrying about declspec
specifier. The EXPORT_IMPORT
macro can also be used to export any other functions you want to export/import.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.