如何解决Visual Studio(LNK2005)中的此链接错误? [英] How can I resolve this link error in Visual Studio (LNK2005)?

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

问题描述

我一直存在以下形式的链接器错误:


libcmtd.dll msvmrtd.dll 某些元素(例如:_mkdir )已经定义了
...


,我不知道如何解决。 p>

以下是完整的错误消息:


private:__thiscall type_info :: type_info( class type_info const&)
(?? type_info @@ AAE @ ABV0 @@ Z)已在
LIBCMTD.lib(typinfo.obj)中定义



MSVCRTD.lib(ti_inst.obj):错误LNK2005:专用:类type_info&
__thiscall type_info :: operator =(class type_info const&)(?? 4type_info @@ AAEAAV0 @ ABV0 @@ Z)已在
LIBCMTD.lib(typinfo.obj)中定义


您能帮我解决这个问题吗?

解决方案

检查几件事:


  1. 头文件是否受到保护,即它们是否具有 #ifndef 警卫。


  2. 您是否在没有内联


  3. 是否要在.cpp文件中定义模板,所有模板定义都必须在头文件。


请发布一些代码和确切的错误文本!


I keep having linker errors of the following form:

libcmtd.dll msvmrtd.dll some element(ex: _mkdir ) already defined...

and I don't know how to resolve them.

Here is a complete error message:

private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)

MSVCRTD.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)

Can you help me solve this issue?

解决方案

Check a few things:

  1. Are your header files guarded. I.e. do they have #ifndef guards.

  2. Are you defining (non-template) functions in headers without the inline keyword. That messes lots of stuff up.

  3. Are you trying to define templates in a .cpp file. All template definitions need to be in headers.

Post some code and exact error text please!

这篇关于如何解决Visual Studio(LNK2005)中的此链接错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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