Search code examples
c++windowscrt

Verifying CRT used in library (.lib)


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.


Solution

  • 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.