作者:朱金灿
来源:http://blog.csdn.net/clever101/
昨天同事请教我一个问题:她的程序老是出现如下的编译错误:
error LNK2019: 无法解析的外部符号 "public: __thiscall CBtt::CBtt(void)" (??0CBtt@@QAE@XZ),该符号在函数 "protected: __thiscall COwnerView::COwnerView(void)" (??0COwnerView@@IAE@XZ) 中被引用
error LNK2019: 无法解析的外部符号 "public: __thiscall CBtt::~CBtt(void)" (??1CBtt@@QAE@XZ),该符号在函数 "public: void * __thiscall CBtt::`scalar deleting destructor'(unsigned int)" (??_GCBtt@@QAEPAXI@Z) 中被引用
1>../outdir/Debug/Owner.exe : fatal error LNK1120: 2 个无法解析的外部命令
的编译错误。
开始我以为她的附加库路径没有设置对,但是一看附加库路径设置对了,而且lib文件也确实存在。然后我用Depends打开她所用到的dll,发现这个dll文件居然一个导出函数都没有。接着我看看她的代码,凭感觉发现一个不自然的地方:
我说这个API_DECLSPEC放置的地方不对,似乎应该是class API_DECLSPEC CBtt。测试一下,改为class API_DECLSPEC CBtt,果然能将类CBtt导出了,外部使用也没有了链接错误。后来我发现写成API_DECLSPEC class CBtt可以成功编译出lib和dll文件,但编译器会出一个警告提示我们:
"__declspec(dllexport)": 没有声明变量时忽略"CBtt"的左侧
分享到:
相关推荐
__declspec(dllexport)和__declspec(dllimport)的区别是什么
在win32sdk / c 命令行下用__declspec(dllexport)导出函数名字和全局变量.
VC 利用关键字_declspec (dllexport)导出函数,编译后将生成Test.dll文件。。。参考价值更大于使用价值。欢迎下载。没有截图哦,因为只有一个DLL。
摘要:VC/C++源码,其它分类,关键字 VC++使用关键字_declspec (dllexport)导出函数,编译后将生成Test.dll文件。
extern "C" __declspec(dllexport) bool TifOpen(char* filename,char* model); extern "C" __declspec(dllexport) bool TifClose(); extern "C" __declspec(dllexport) int GetTifWidth(); extern "C" __declspec...
declspec(dllexport)与_declspec(dllimport)的区别
摸索了两天了,终于解决了所有问题,在此跟大家分享。...#define DLL_DEMO extern "C" __declspec(dllexport) #else #define DLL_DEMO extern "C" __declspec(dllimport) #endif DLL_DEMO int __stdcall Add(int a, int
__declspec(dllexport) windows到linux的转换: windows下: #include #include #include #include using namespace std; #define FF(a,b) for(a=0;a<b;a++) extern C { __declspec(dllexport) void ...
本人将其转成了VS2010 如果要将工程转成BCB: ...修改TaskKeyHook.cpp的宏定义 #define DLLEXPORT extern "C" __declspec(dllexport) 2.重新编译生成TaskKeyHook.DLL 3.请运行bcbDll.bat导出TaskKeyHook.dll的lib文件
用C语言写控制的全桥LLC PSIM仿真,要的拿走,包含PSIM仿真文件,c语言源代码控制DLL文件。需要的拿走
一步一步学习Visual Studio 2015 Community创建DLL,整体来看和Visual ...#define VSAPI _declspec(dllexport) #else #define VSAPI _declspec(dllimport) #endif #define EVSAPI extern "C" VSAPI #endif
#define ZRD_Com __declspec(dllexport) #else #define ZRD_Com __declspec(dllimport) #endif // Receive Data Function typedef void(_stdcall *OnReceive)(const char* Result,int count); // OpenCom // ...
C++builder 6 装上插件即可使用 ...下一页:extern "C" __declspec(dllexport) void oa_next(LPDISPATCH lpDisp); 上一页:extern "C" __declspec(dllexport) void oa_previous(LPDISPATCH lpDisp);
extern "C" __declspec(dllexport) int add(int a, int b); 加载动态库 HMODULE hmododule = LoadLibrary(L"Win32Project1"); 定义函数指针 typedef int(*padd)(int a, int b); 获取函数地址 padd pAdd = (padd)...
__declspec(dllexport)和__declspec(dllimport): __declspec(dllexport):编译器看到一个变量、函数或者C++类被它修饰,那么它就知道应该在生成的DLL 模块中导出该变量、函数或C++类。 __declspec(dllimport):...
该示例包含__declspec(dllexport)和def两种制作方式,包含隐式和显式两种调用方式。
__declspec(dllexport) int WINAPI MYFIRST(CALCINFO* pData) { float f,fTotal; int i,j,k,m; // 定义变量 if(pData->m_pfParam1 && //参数1有效 pData->m_pfParam2==NULL) //只有1个参数 // 检查分析家传过来的...