Linker diagnostic Visual Studio C++
LNK4098 defaultlib conflicts with use of other libs
The object files and libraries of the program were compiled with different C runtime libraries, such as /MD and /MT, or Debug and Release. The program may crash when memory or objects cross between them.
Visual Studio property-page paths describe MSBuild projects. For CMake, configure the corresponding target or preset. Menu names can vary by Visual Studio version; use the cited reference for your toolset.
warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:libraryCauses & corrections
Find the case that matches your build. Each example shows what changes and why.
A library uses another runtime library.
Build all projects and libraries with the same C/C++ > Code Generation > Runtime Library:
/MDwith/MDdin Debug, or/MTwith/MTd. Use the library build that matches.Problem
App: /MDVendor library: /MTCorrection
App: /MDVendor library: matching /MD buildNote 1Use compatible runtime variants instead of default-library suppression. A Release library is linked in Debug.
Link the Debug build of the library in the Debug configuration.
Problem
App: Debug (/MDd)Core: Release (/MD)Correction
App: Debug (/MDd)Core: Debug (/MDd)Note 2Keep Debug dependencies separate from Release dependencies. /NODEFAULTLIBhides the conflict.Ignoring the default library silences the warning without making the runtimes compatible: use it only for a library you know is not needed.
Problem
Mixed /MD and /MT objectsAdditional Options: /NODEFAULTLIB:MSVCRTCorrection
Rebuild or replace mismatched objectsUse compatible runtime settingsRemove the suppression hiding this mismatchNote 3Suppressing a library does not make incompatible runtime ownership safe.
Sources and scope
Official references
These links document the compiler, build system, or debugger behavior discussed here. Use the version selector on Microsoft Learn for your toolset. Example blocks are focused excerpts; required headers and build settings are stated alongside them.
In your workspace
Investigate LNK4098 with CppPilot
CppPilot gives the selected AI the diagnostic, relevant code, and project settings for the active configuration. Choose Fix to request a correction, then check the result with a rebuild.
Use your own Codex or Claude account, or optional CppPilot Cloud access. Setup instructions
Visual Studio Marketplace