Error Lnk2005: Xxx Already Defined in Msvcrt.Lib(Msvcr100.Dll) C:\Something\Libcmt.Lib(Setlocal.Obj)

error LNK2005: xxx already defined in MSVCRT.lib(MSVCR100.dll) C:\something\LIBCMT.lib(setlocal.obj)

You are mixing code that was compiled with /MD (use DLL version of CRT) with code that was compiled with /MT (use static CRT library). That cannot work, all source code files must be compiled with the same setting. Given that you use libraries that were pre-compiled with /MD, almost always the correct setting, you must compile your own code with this setting as well.

Project + Properties, C/C++, Code Generation, Runtime Library.

Beware that these libraries were probably compiled with an earlier version of the CRT, msvcr100.dll is quite new. Not sure if that will cause trouble, you may have to prevent the linker from generating a manifest. You must also make sure to deploy the DLLs you need to the target machine, including msvcr100.dll

What is causing VS2013 error LNK2005: __xi_a already defined in MSVCRT.lib(cinitexe.obj)?

Something is causing both runtimes to be linked in.

First try cleaning (manually) all .obj and .lib files that your project creates and rebuild it.

If that doesn't help, set the linker's /VERBOSE flag ("Linker | General | Show Progress" = "Display all progress messages (/VERBOSE)" in the IDE).

Then look at the output; in the IDE it'll be in the build output directory in a file called <project-name>.log.

You'll see where each library is searched and what object file is causing the library to be searched.


Update:

The log output shows that LIBCMT.lib is being searched due to a DEFAULTLIB directive in one or more of the object files being processed (which may be an object file from a library).

However, it's not clear to me form the log output which input(s) is responsible - I think it's glew32s.lib (the glew.obj object in it).

See this SO answer for a way to find which .obj/.lib files have a DEFAULTLIB directive.

You might get away with setting the /NODEFAULTLIB:libcmt.lib option in the project properties ("Ignore Specific Default Libraries").

Error 22error LNK2005: _realloc already defined in libcmt.lib(realloc.obj) MSVCRT.lib

Never ignore such linker errors where it seams that 2 different CRT versions (static/DLL or may be Debug) are used.

Fix your object modules so that they only use one CRT version! Ignoring such an error is the wrong way, because different heaps may be used inside your program!

__crt_debugger_hook defined in both ucrtd.lib and msvcrtd.lib?

It turns out that the bug isn't in Microsoft's library. Instead it's in the Crypto++ (https://www.cryptopp.com/) library. They forward declare _crt_debugger_hook in a way that is incompatible with changes that were made by Microsoft when they split the c-runtime into ucrtd.lib and msvrtd.lib. The offending line is fipstest.cpp at line 21:

extern "C" {_CRTIMP void __cdecl _CRT_DEBUGGER_HOOK(int);}

the _CRTIMP needs to be removed so that you have

extern "C" {void __cdecl _CRT_DEBUGGER_HOOK(int); }

I've opened a pull request with the Crypto++ folks to fix this (https://github.com/weidai11/cryptopp/pull/151).

error LNK2005 already defined in card.obj

#include "card.c"

It's probably a better idea to include the header file rather than the C file.

The latter will cause duplicate symbols if you link the main object file and the card object file since main includes the exact same code as card (as a subset).



Related Topics



Leave a reply



Submit