When I try to build my sources linking with libeay32.lib. I have built this locally from OpenSSL sources. I encountered the above warning "LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library". When I debug my exe, whenever there is some system call (like read()), Exe crashes. After some search, I could find that this is some thing related to 'Runtime Library' MT and MD. I can't fix this by building openssl sources due to some reasons. As of now, what I did is I kept the entry "MSVCRT.lib" at Ignore Specific Library I have to do this for several other libraries. Which I don't want to. Is there any other Optimal solution.
-
can you please post some code? – Gianmarco Sep 04 '13 at 11:20
4 Answers
If i understand it right you are mixing a release version of OpenSSL with a debug version of your program that causes different CRT versions to be used, since you haven't posted actual settings it may be even worse that OpenSSL is using DLL CRT while your code static. Please post what kind of CRT is your program using (can be found by clicking Properties
on the project and then Configuration Properties -> C/C++ -> Code Generation -> Runtime Libarary
). Either use proper OpenSSL version (e.g. build it with debug info and linked to debug CRT) or, since you are stating you cannot recompile OpenSSL, compile your code with Multi-threaded DLL
in release without optimizations so you get a program that can be debugged and uses the same CRT as OpenSSL. That should solve it I guess.

- 11,636
- 6
- 33
- 71
The Visual Studio compiler have two modes when building: Multi-threaded and not multi-threaded. You set the mode when you create a project, and can change it later in project settings.
The problem here is that these two modes are not compatible. If you mix multi-thrading and non-multi-threading libraries then you will get errors like those you have. Either recompile the other library with the other mode, or change the mode of your project to match that of the library.

- 400,186
- 35
- 402
- 621
-
I cannot do this due to some reasons. Any other solution?? – Praneeth Kumar Gunda Sep 04 '13 at 11:16
-
1Why can't you match your library which you are developing with OpenSSL settings? Maybe your's is the only using static CRT. If some other external dependencies use static CRT too then you are in a hard situation, but if the one conflicting with `MSVSCRT` is yours, the right way would be to change your configuration. – Rudolfs Bundulis Sep 04 '13 at 11:56
-
@Someprogrammerdued, can we not create a C wrapper around the dependency which uses MT/MD, into a dll. and at runtime, simply load the methods that we need in a project built with the different switch. (for example, the project is built with `/MT` while the lib is built in `MD`. We create a c wrapper for the lib, and then load the new dll at runtime. will that be OK or will it result in an exception at runtime? – Hossein Dec 12 '20 at 05:50
This conflict comes up when using different flavors of the Microsoft C-Runtime libraries. Here is an overview: http://msdn.microsoft.com/en-us/library/abx4dbyh.aspx
So f.e. if you are linking to msvcrt.lib (dynamic, multithreaded CRT) and one of your dependencies is linked against the libcmtd.lib (static, multithreaded) this warning comes up. This situation may lead to subtle errors and can cause all sort of problems which are hard to debug. There is not much you can do to get rid of the warning than set the conflicting library to the ignore list and hope for the best if you have no control over the dependencies. In general it is a good idea to use the same C/C++ runtime linkage for all dependencies and the program itself.

- 428
- 2
- 7
The thing is that you are linking your application to the runtime dynamically /MD in the VS (by default, which means that you should provide the Visual Studio Redistributable Package with your app).
Properties -> Configuration Properties -> C/C++ -> Code Generation -> Runtime Library
Whereas the opensll lib by default links to the runtime statically (runtime contains for example the implementation of the STL). It is not good to mix the runtime linking thus the warning. You can fix the problem by recompiling the opensll library using dynamic linking to the runtime.
Please follow: http://developer.covenanteyes.com/building-openssl-for-visual-studio/ then in the
ms\nt.mak
change \MT
to \MD
before running nmake -f ms\nt.mak
and nmake -f ms\nt.mak install

- 31
- 2