Visual Studio的链接错误LNK2005 LNK2020和

问题描述:

我使用Visual Studio 2003和我得到在我的项目下列链接错误:Visual Studio的链接错误LNK2005 LNK2020和

Linking... 
LINK : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification 
msvcrtd.lib(MSVCR71D.dll) : error LNK2005: _fprintf already defined in LIBCMTD.lib(fprintf.obj) 
C:\Documents and Settings\mz07\Desktop\project\HLconsoleExample\Debug\HLconsoleExample.exe : fatal error LNK1169: one or more multiply defined symbols found 

我遂把libcmtd.lib成“忽略特定的图书馆”行并得到了另一个错误:

Linking... 
LINK : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification 
LINK : error LNK2020: unresolved token (0A000037) _CxxThrowException 
LINK : error LNK2020: unresolved token (0A000039) delete 
LINK : fatal error LNK1120: 2 unresolved externals 

这是我的主类的开头:

#include <cstdio> 
#include <iostream> 

#if defined(WIN32) 
# include <conio.h> 
#else 
# include "conio.h" 
#endif 

#include <HL/hl.h> 
#include <HD/hd.h> 

#include <HDU/hduVector.h> 
#include <HDU/hduError.h> 
... 
int main(int argc, char *argv[]) 
{ 
    HHD hHD; 
    HHLRC hHLRC; 
    HDErrorInfo error; 
... 
} 

我将我用到链接器属性中的所有库都包括在内。下面是它的命令行输出:

/OUT:"C:\Documents and Settings\mz07\Desktop\project\HLconsoleExample\Debug\HLconsoleExample.exe" /INCREMENTAL /NOLOGO /NODEFAULTLIB:"libcmtd.lib" /DEBUG /ASSEMBLYDEBUG /PDB:"C:\Documents and Settings\mz07\Desktop\project\HLconsoleExample\Debug/HLconsoleExample.pdb" /FIXED:No hl.lib hd.lib HDUD.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib "\Program Files\SensAble\3DTouch\lib\hl.lib" "\Program Files\SensAble\3DTouch\lib\hd.lib" "\Program Files\SensAble\3DTouch\utilities\src\Hdu\Debug\HDUD.lib" 

我新的C++和我真的不知道如何联系起来的作品:)所以任何帮助表示赞赏。

您正在链接其代码已编译为不兼容的编译器设置的.lib。问题一是Project + Properties,C/C++,代码生成,运行时库。/MD与/ MT不兼容。您将不得不重建.libs以匹配您的.exe项目设置或其他方式。

+0

非常感谢。我明天会尝试 – Student 2010-01-22 16:02:59