licensecc_static.lib(licensecc.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' d
oesn't match value 'MD_DynamicRelease' in Main.obj
I externally compiler licensecc_static.lib as static library and I’m trying to link it to executable.
Also I link few shared libs to the same executable.
The runtime of all objects (including those from libs) must match.
Currently you’re compiling your library against the static and Main.obj against the DLL runtime. Both in release, not debug mode.
The manual of MSVC_RUNTIME_LIBRARY shows all 4 possible values.
It seems I don’t understand something.
For now I just compiled licensecc library without -DSTATIC_RUNTIME=1 even though it is recommended to set it to 1. It works if it is 0 (no mentionned errors).
But what STATIC_RUNTIME really changes?
As I see if I pass STATIC_RUNTIME=1 then /MT flag is added (link for the code).
Why adding /MT flag leads to mentionned error: after all the library is added using ADD_LIBRARY(licensecc_static STATIC ${sources}) - it is still static.
The type of the MSVC runtime is unrelated to the type of library you want to build. It’s totally possible to use the static runtime with a DLL, or the dynamic runtime with a static library.