多个 LNK2005 错误 [英] Multiple LNK2005 errors

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

问题描述

我正在编译一个项目并出现以下错误:

I'm compiling a project and have the following errors:

  LIBCMTD.lib(_file.obj) : error LNK2005: ___iob_func already defined in      MSVCRTD.lib(MSVCR90D.dll)
  LIBCMTD.lib(dbgheap.obj) : error LNK2005: __CrtSetCheckCount already defined in MSVCRTD.lib(MSVCR90D.dll)
  LIBCMTD.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRTD.lib(MSVCR90D.dll)
  LIBCMTD.lib(crt0dat.obj) : error LNK2005: __exit already defined in MSVCRTD.lib(MSVCR90D.dll)
  LIBCMTD.lib(crt0dat.obj) : error LNK2005: __cexit already defined in MSVCRTD.lib(MSVCR90D.dll)
  LIBCMTD.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVCRTD.lib(MSVCR90D.dll) 
  LIBCMTD.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in MSVCRTD.lib(MSVCR90D.dll)
  LIBCMTD.lib(fflush.obj) : error LNK2005: _fflush already defined in MSVCRTD.lib(MSVCR90D.dll)
  LIBCMTD.lib(dbghook.obj) : error LNK2005: __crt_debugger_hook already defined in MSVCRTD.lib(MSVCR90D.dll)
  LIBCMTD.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in MSVCRTD.lib(MSVCR90D.dll)
  LIBCMTD.lib(setlocal.obj) : error LNK2005: __configthreadlocale already defined in MSVCRTD.lib(MSVCR90D.dll)
  LIBCMTD.lib(tidtable.obj) : error LNK2005: __encode_pointer already defined in MSVCRTD.lib(MSVCR90D.dll)
  LIBCMTD.lib(tidtable.obj) : error LNK2005: __decode_pointer already defined in MSVCRTD.lib(MSVCR90D.dll)
  LIBCMTD.lib(sprintf.obj) : error LNK2005: _sprintf already defined in MSVCRTD.lib(MSVCR90D.dll)
  LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRTD.lib(cinitexe.obj)
  LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRTD.lib(cinitexe.obj)
  LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRTD.lib(cinitexe.obj)
  LIBCMTD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRTD.lib(cinitexe.obj)

当我删除两个库时,这些错误不再出现,但我有一些未解决的内部符号错误.所以我必须维护这些库.有没有办法可以忽略已经定义的函数,这样我就不会出现 LNK2005 错误?

When I remove two libraries, those errors stop appearing, but I have some unresolved internal symbols errors. So I have to maintain those libraries. Is there a way that I can ignore already defined functions so I don't have the LNK2005 error?

推荐答案

您正在将您的项目与两个版本的运行库链接:LIBCMTD.lib(静态多线程调试)和 MSVCRTD.lib(多线程调试 DLL).如果不了解有关您的设置的更多信息,就不可能说这两个版本如何同时出现在您的项目中.

You are linking your project with two versions of run-time library: LIBCMTD.lib (static multithreaded debug) and MSVCRTD.lib (multithreaded debug DLL). How come both of these two versions are present in your project at the same time is impossible to say without knowing more about your setup.

如果您将第三方库添加到需要不同版本的运行时库的项目中,则可能会发生这样的事情.

Things like that might happen if you add third-party libraries to your project that demand different versions of run-time library.

这通常可以通过使用

项目属性 ->链接器 ->输入 ->忽略特定的默认库

在项目属性中为您的可执行文件设置.决定要使用哪个库(LIBCMTD.libMSVCRTD.lib)并要求链接器忽略另一个.

setting in Project Properties for your executable. Decide which library you want to work with (LIBCMTD.lib or MSVCRTD.lib) and ask the linker to ignore the other one.

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

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