我有一个用 vc10 (VS2010) 编译的第三方 DLL。它导出以下函数:
bool myDLL_EXPORTS_API myFunction(std::vector<int>::const_iterator c)
{
return true;
}
我的 exe 使用这个 DLL。我正在尝试使用 vc11 (vs2012) 编译我的 exe。
#include "stdafx.h"
#include <vector>
#include "myDll_VC10\myDll_VC10.h"
int _tmain(int argc, _TCHAR* argv[])
{
std::vector<int>::const_iterator c;
myFunction(c);
return 0;
}
我收到以下链接器错误:
1>使用DLLvc10.obj:错误LNK2019:无法解析的外部符号“__declspec(dllimport) bool __cdecl >myFunction(class std::_Vector_const_iterator > >)”(_ imp ?myFunction@@YA_NV?$_Vector_const_iterator@V?$_Vector_val@U? >$_Simple_types@H@std@@@std@@@std@@@Z) 在函数 _wmain 1>C:\Work\Training\vectorReproduceBug\usingDLLvc10\Debug\usingDLLvc10.exe 中引用:致命错误 LNK1120:1>未解决外在
注意:如果我的 exe 是用 vc10 (VS2010) 编译的,则此代码会编译并链接。如果没有使用 vc11 (VS2012) 编译的第三方库,如何修复此链接器错误?