2013-07-10 45 views
2

我有一个第三方DLL编译与VC10(VS2010)。 它导出以下功能:LNK1120错误 - VS2012项目使用VS2010 DLL

bool myDLL_EXPORTS_API myFunction(std::vector<int>::const_iterator c) 
{ 
return true; 
} 

我的EXE使用此DLL。我试图用vc11编译我的exe(vs2012)。

#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>usingDLLvc10.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) bool __cdecl >myFunction(class std::_Vector_const_iterator > >)" (_imp[email protected]@[email protected][email protected]?>[email protected]@[email protected]@@[email protected]@@[email protected]@@Z) referenced in function _wmain 1>C:\Work\Training\vectorReproduceBug\usingDLLvc10\Debug\usingDLLvc10.exe : fatal error LNK1120: 1 >unresolved externals

注:此代码编译和链接,如果我的exe与VC10(VS2010)编译。 如何解决此链接器错误,而没有使用vc11(VS2012)编译的第三方库?

回答

4

你基本上不行。编译后的二进制文件根据您用于编译的编译器不同而不同,因此vs2010生成的DLL与vs2012不兼容。解决这个问题的唯一方法是将旧的2010库从源代码重新编译为2012版本。