Verifying CRT used in library (.lib)
Asked Answered
W

2

12

How do I check what runtime library a static library (.lib) in Windows has linked to?

I'm compiling my project with /MDd and I presume a library I'm linking to is using /MTd Multi-threaded Debug

Error   7   error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in libcpmtd.lib(xlock.obj)    C:\...\msvcprtd.lib(MSVCP100D.dll)

LIBCPMTD.LIB = Multithreaded, static link

I know there's an option /NODEFAULTLIB:"libcpmtd.lib" which I've tried and succeeded with, but I'd rather avoid that.

Winder answered 21/3, 2011 at 9:24 Comment(0)
W
7

I was able to fix this doing the following

> dumpbin /DIRECTIVES C:\..\ThirdParty\tidy\windows\lib\libtidy
.lib
Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.


Dump of file C:\..\ThirdParty\tidy\windows\lib\libtidy.lib

File Type: LIBRARY

   Linker Directives
   -----------------
   /DEFAULTLIB:"LIBCMT"
   /DEFAULTLIB:"OLDNAMES"
...

It's cleary linking to MT. I recompiled the lib using /MDd and it linked fine.

Winder answered 21/3, 2011 at 10:12 Comment(1)
That's cool, but if I have "MSVCRT" for /MD, how do I find a particular version of Visual Studio used? I.e. which MSVCRTxx.dll is referenced?Hallucinosis
A
0

Since MSVPRTD.LIB is the importlib of the dynamic link library of the crt, while you explicitely asked to link to the crt statically, something seems wrong with your build chain.

You may want to check the project file visually for contradictions.

Almallah answered 21/3, 2011 at 9:33 Comment(1)
The project I'm trying to compile is using /MDd which is the correct setting. Something I'm trying to link to is using /MT(d) static or what not. How does Visual Studio 2010 help in detecting which of the library I link to has a conflicting CRT? Is there no option to manually inspecting all the project files?Winder

© 2022 - 2024 — McMap. All rights reserved.