如何解决Visual Studio(LNK2005)中的此链接错误? [英] How can I resolve this link error in 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)中定义
您能帮我解决这个问题吗?
检查几件事:
-
头文件是否受到保护,即它们是否具有
#ifndef
警卫。 -
您是否在没有
内联$的标头中定义(非模板)函数
-
是否要在.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:
Are your header files guarded. I.e. do they have
#ifndef
guards.Are you defining (non-template) functions in headers without the
inline
keyword. That messes lots of stuff up.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屋!