Visual Studio链接错误LNK2005和LNK2020 [英] Visual Studio linking error LNK2005 and LNK2020

查看:191
本文介绍了Visual Studio链接错误LNK2005和LNK2020的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio 2003,并且在我的项目中遇到以下链接错误:

I'm using visual studio 2003 and I'm getting the following linking error in my project:

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包含在忽略特定库"行中,并得到另一个错误:

I then included libcmtd.lib into "ignore specific library" line and got another error:

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

这是我的主要课程的开始:

This is the beginning of my main class:

#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;
...
}

我将我正在使用的所有库都包含在链接器属性中.这是它的命令行输出:

I included all the libraries I'm using into the Linker properties. Here is the Command Line output of it:

/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 ++的新手,我不太了解链接的工作原理:),所以不胜感激.

I am new to c++ and I don't really understand how linking works :) so any help is appreciated.

推荐答案

您正在链接一个.lib,该lib的代码使用不兼容的编译器设置进行编译.问题之一是项目+属性,C/C ++,代码生成,运行时库. /MD与/MT不兼容.您将不得不重新构建.lib以匹配您的.exe项目设置,或者相反.

You are linking a .lib whose code was compiled with an incompatible compiler setting. The problem one is Project + Properties, C/C++, Code Generation, Runtime library. /MD is not compatible with /MT. You'll either have to rebuild the .libs to match your .exe project setting or the other way around.

这篇关于Visual Studio链接错误LNK2005和LNK2020的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆