[visual-studio] Resolving LNK4098: defaultlib 'MSVCRT' conflicts with
It means that one of the dependent dlls is compiled with a different run-time library.
Project -> Properties -> C/C++ -> Code Generation -> Runtime Library
Go over all the libraries and see that they are compiled in the same way.
More about this error in this link:
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
is a fairly common warning in Visual Studio. I'd like to understand the exact reason for it and the right way (if at all) to handle it.
This comes up in a debug build, compiled with
/MDd. The project is linked to things like windows
pdh.dll which themselves link with
MSVCRT.dll. Obviously, I don't have the debug versions of these and can't compile them.
So I added
/NODEFAULTLIB:MSVCRT to the linker command line and it actually did remove the warning. But what does this actually do? And why is it necessary?
I get this every time I want to create an application in VC++.
Right-click the project, select Properties then under 'Configuration properties | C/C++ | Code Generation', select "Multi-threaded Debug (/MTd)" for Debug configuration.
Note that this does not change the setting for your Release configuration - you'll need to go to the same location and select "Multi-threaded (/MT)" for Release.