Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Verifying CRT used in library (.lib)

Tags:

c++

windows

crt

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.

like image 987
Mohamed Bana Avatar asked Mar 21 '11 09:03

Mohamed Bana


People also ask

What are the contents of .LIB file?

A LIB file contains a library of information used by a specific program. It may store a variety of information, which may include functions and constants referenced by a program or actual objects, such as text clippings, images, or other media.

What is .LIB file in Visual Studio?

The Microsoft Library Manager (LIB.exe) creates and manages a library of Common Object File Format (COFF) object files. LIB can also be used to create export files and import libraries to reference exported definitions. You can start this tool only from the Visual Studio command prompt.

What is UCRT lib?

The Universal CRT (UCRT) contains the functions and globals exported by the standard C99 CRT library. The UCRT is now a Windows component, and ships as part of Windows 10 and later versions. The static library, DLL import library, and header files for the UCRT are now found in the Windows SDK.


1 Answers

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.

like image 179
Mohamed Bana Avatar answered Oct 06 '22 15:10

Mohamed Bana