0

I have run into this problem, which although is a warning, I suspect is a sign of something wrong under the hood. When I build in release mode I get this warning:

MSVCRT.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrtd.lib' conflicts with use of other libs; use /NODEFAULTLIB:library

I'm building a dynamic DLL in Visual Studio C++ Express Edition. When I do it in debug mode no warning arises. I've googled a bit and it looks like msvcrt and msvcrtd are both for multithreading, one for debugging and the other not. I could use /NODEFAULTLIB with MSVCRT.lib, but I don't think that avoiding symptoms really helps with the problem.

I really don't know if this is a huge problem. The DLL and .lib files are generated correctly.

2
  • 1
    The release version should include only msvcrt.lib and not msvcrtd.lib. Are you sure you did not add something by mistake?
    – casablanca
    Nov 26, 2010 at 18:14
  • I see that you are new here. If any of the answers below help fix your problem, then please mark the answer as "accepted". :) Nov 26, 2010 at 22:14

3 Answers 3

0

Check that your runtime library settings are correct in the Release configuration of your project. Basically it should be the same as your Debug build, but without the word 'Debug' in the description. Visual Studio docs on this issue are here.

Check your settings as follows:

  • in Solution Explorer right click the Project and select Properties
  • make sure the Configuration (at the top of the Properties window) is Active (Release)
  • go to Configuration Properties -> C/C++ -> Code Generation
  • check that Runtime Library for Release is not a Debug version of the CRT.
0

The problem is related to your libraries. They are linked differently than your program.

Your program may be single-threaded, while your libraries may be linked as multithreaded, for example.

Look under

Project Properties 
Configuration Properties
C/C++ 
Code Generation 
Runtime Library

to see the setting (e.g. "Multi-threaded Debug DLL (/MDd)").

0

This is a huge problem, since it can lead to many unexpected crashes of your application, AND you can't distribute an application which links msvcrtd.lib, since you are not allowed to distribute the debug C++ runtimes of Visual Studio. Though /NODEFAULTLIB should fix those, you should fix the issue itself.

Like casablanca said, msvcrtd.lib is linked in release mode, but it should only be linked in debug mode. This does not mean that your own application has wrong linker settings. Any of the libraries you use in your project could have incorrect settings as well.

What I usually do to fix this is, to open all the release .lib files which your application links, with a text editor which can open such large binary files (like SciTE), and then I search them for e.g. VC80.DebugCRT (VC80 == Visual Studio 2005 in this case), and if I find this string in one of those libraries, that library should be recompiled with /MD.

If you are linking dynamic libraries, you can use a tool called Dependency Walker on the .dll files instead of manually searching the .lib files. If Dependency Walker shows the dependency on one of the debug crt DLL files like e.g. MSVCP80D.dll (note the trailing D), recompile that library using /MD.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.