How to resolve this link error in Visual Studio (LNK2005)

crtmsvcrtvisual c++visual-studio-2005

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?

Best Answer

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!

Related Topic