Im writing a code and included many library files (.lib) with it , when i compile all is fine 0 errors and 0 warnings , but when i built i got problems.
when using VC 6.0 i got this warning

LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library

i tried my code on VC2008 (when compiled all is ok) when i linked i got a warning + 2error messages

MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) already defined in LIBCMTD.lib(typinfo.obj)
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
.\Debug/project.exe : fatal error LNK1169: one or more multiply defined symbols found

Please note that i didnt add the libraries stated in the warnings or errors to my project.

What should i do ? any help is appreciated.Thanks

Dani AI

Generated

Mixing different Microsoft C/C++ runtimes (static vs dynamic, or debug vs release) is the usual root cause of the linker warning and the follow‑on “multiply defined” errors reported earlier. That warning (LNK4098) means the linker is seeing default libraries that disagree; the duplicate‑symbol errors (LNK2005) often appear when both runtimes pull the same C++ runtime symbols into the link. (learn.microsoft.com)

A practical way to diagnose which module forces which runtime: inspect the third‑party .lib/.obj files with DUMPBIN and make the linker show what it searches. From a VS command prompt:

dumpbin /DIRECTIVES path\to\thirdparty.lib | find /i "DEFAULTLIB"

and turn on Linker → General → Show Progress = "For Libraries Searched" (equivalent to /VERBOSE:LIB) to see which default libs the linker actually pulls in. Those outputs will show /DEFAULTLIB:MSVCRT, /DEFAULTLIB:LIBCMT, /DEFAULTLIB:MSVCRTD, etc., which identifies the runtime each module wants. (stackoverflow.com)

Remedies, in order of safety: (1) rebuild all code with the same Runtime Library setting (Project → C/C++ → Code Generation → Runtime Library) so every module uses /MD, /MDd, /MT or /MTd consistently; (2) ask the library vendor for a build that matches the chosen runtime (or supply a matching variant); (3) if source is not available, isolate the third‑party code behind a DLL boundary so memory/CRT resources don’t cross module boundaries. The runtime options and their corresponding default libs are documented by MSVC. (learn.microsoft.com)

Avoid /NODEFAULTLIB as a first fix: it can silence the warning but hide real ABI/runtime incompatibilities and lead to subtle runtime crashes (especially when heaps or C++ objects cross module boundaries). If used as a last resort, add the exact library names to Linker → Input → Ignore Specific Default Libraries and then thoroughly test both debug and release builds. The MS docs describe the ignore option and warn about mixing runtime libraries. (learn.microsoft.com)

Note: ’s prompt about project type was important — Win32 vs DLL vs console influences how runtimes are linked — and ’s report that the CodeProject method removed the messages likely means the conflicting default lib was suppressed. Best practice is still to make the runtime choices consistent or obtain matching library builds rather than only suppressing linker warnings.

Recommended Answers

All 4 Replies

1) What kind of project did you create? console, win32 windows, something else?

2) what libraries did you try to link with?

i think i found the solution i used


i removed the warning message i got when building in VC6.0, i still didn't try it on the VC2008 to see if it fixed the errors i don't have access to VC2008 right now, ill post tomorrow if it worked there too.

thanks for the reply ancient dragon sorry didnt see your post , its a windows 32 application i simply created a source file and added .lib files to it, the .lib files are actually 3rd party files that were supplied to me with their .dlls in order to control certain hardware using open source code

hi all i checked the VC2008 and it also solved the issue there too, i hope that the method stated in the link above solved the problem rather than shutting the warning messages up ,thus hiding greater problems yet to be seen.
Thanks for all

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.