3

Recently, I compiled zlib, openssl, libSSH2 and libcurl with Visual Studio 2017. All of them had /MD option, but I can use them in my project which use /MT option.

But with other libraries, like JsonCpp, PugiXML and so on, I cannot link them to my project because they had MD option and resume linking by LNK2038 error

fmts.lib(format.obj) : error LNK2038: discordance détectée pour 'RuntimeLibrary' : la valeur 'MD_DynamicRelease' ne correspond pas à la valeur 'MT_StaticRelease' in 4DPlugin.obj

What i don't understand is why libcurl can be linked by a project with /MT or /MD option and JsonCpp can't.

Is it possible to make these libraries compatible both MT and MD options, or zlib, openssl, libSSH2 and libcurl have something special ?

GLCraft
  • 144
  • 7
  • zlib, openssl, etc are C libraries. JsonCpp and PugiXML are C++ libraries. Is that the difference? – Martin Bonner supports Monica Jan 30 '18 at 13:15
  • It is, you right. But they're all using Runtime Library (with new and malloc for example), isn't ? – GLCraft Jan 30 '18 at 13:23
  • C will use malloc but not new – Martin Bonner supports Monica Jan 30 '18 at 13:33
  • related: https://stackoverflow.com/questions/14714877/mismatch-detected-for-runtimelibrary – harper Jan 30 '18 at 13:37
  • Yes, but both malloc and new come from Runtime Lib, so are dependant to MD and MT options, whatever the language used ? @harper No i don't think so. I know how to correct the problem, what i don't know is why there's no problem with C libraries. – GLCraft Jan 30 '18 at 13:39
  • @MartinBonner `/MD` and `/MT` are unrelated to C/C++. These options add linker comments to the object files. The linker collects all this kind of comments and issues LNK2038 on mismatch. That's the annoying thing. But /MT and /MT should also generate different code,although I couldn't find any difference in the non-comment sections of any object file in **my projects**. I don't have any prove that this is the true in general. – harper Jan 30 '18 at 13:43
  • @harper /MD and /MT are not directly related to C and C++, but the OP has a problem. I was pointing out that it appears he can link a mismatched C library, but not a mismatched C++ library. – Martin Bonner supports Monica Jan 30 '18 at 15:38

0 Answers0