I use CMake with
CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS to automatically generate both a shared dll and static .lib library on Windows when building with MSVC. I found out yesterday that the static .lib uses dynamic linking and hence requires using the
/MD compiler option (instead of
/MT). This is a bit surprising to me, why does it not use static linking for static .lib files?
In the CMake documentation (https://cmake.org/cmake/help/latest/prop_tgt/MSVC_RUNTIME_LIBRARY.html) I found:
MSVC_RUNTIME_LIBRARY: “If this property is not set then CMake uses the default value
MultiThreaded$<$<CONFIG:Debug>:Debug>DLL to select a MSVC runtime library.”
What is the reason for using MultiThreadedDLL by default (instead of MultiThreaded) for static .lib files? Maybe that is a good choice and I just fail to understand…