Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I resolve this link error in Visual Studio (LNK2005)?

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?

like image 424
Cute Avatar asked Jun 04 '09 07:06

Cute


People also ask

What is an unresolved external symbol in C++?

The unresolved external symbol is a linker error that indicates it cannot find the symbol or its reference during the linking process. The error is similar to “undefined reference” and is issued interchangeably.


2 Answers

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!

like image 187
rlbond Avatar answered Oct 12 '22 10:10

rlbond


Your problem is that you're linking with two files providing the same symbol.

You haven't provided the real error message so we can't tell you exactly what the problem is but it's likely to be that you're linking with libraries from two different versions of Visual Studio.

There are also solutions available by searching the web (I assume you did this but just missed the articles in question :-) that suggest you can fix the problem by changing the project options from "Multi-threaded Debug(/MTd)" to "Multi-threaded Debug DLL (/MTD)" but I haven't looked in to this.

Please post the complete error so we can offer more targeted assistance.

like image 4
paxdiablo Avatar answered Oct 12 '22 09:10

paxdiablo