Why does the MSCVRT library generate conflicts at link time? [duplicate]
-
23-09-2019 - |
문제
This question already has an answer here:
I am building a project in Visual C++ 2008, which is an example MFC-based app for a static C++ class library I will be using in my own project soon. While building the Debug configuration, I get the following:
warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
After using the recommended option (by adding "msvcrt" to the "Ignore specific library" field in the project linker settings for the Debug configuration), the program links and runs fine. However, I'd like to find out why this conflict occured, why do I have to ignore a critical library, and if I'm to expect problems later I if add the ignore, or what happens if I don't (because the program builds anyway).
At the same time, the Release configuration warns:
warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:ICF' specification
warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
I'm guessing that the "D" suffix means this is the debug version of the vc++ runtime, no idea why this gets used this time. Anyway, adding "msvcrtd" to the ignore field causes lots of link errors of the form:
error LNK2001: unresolved external symbol __imp___CrtDbgReportW
Any insight greatly appreciated.
해결책
This usually happens when you link against a static library that uses another version of the VC++ runtime (C++ ->Code Generation->Runtime Library
setting in the project properties).
다른 팁
This usually happened to me when I was (inadvertently) mixing different flavours of the RTL, like (as it seems to be in your case) Debug and Release or MT and ST.