Reputation: 1775
Regarding this Stack Overflow question: How bad is it to mix and match Visual C++ runtime DLL files in one process?
I know I can expect heap corruption by using a different version of MSVCR at runtime.
But let's imagine the following situation that can't work:
libA
is a shared library which links against MSVCR71
Exe
is my program that links against libA
and MSVCR100
I have then the following dependency scheme:
Exe +--> libA ---> MSVCR71
+--> MSVCR100
THAT is, the thing I KNOW I shouldn't do!
BUT what if now, I compile libA
as a static library with whatever Visual Studio that uses MSVCR71
and I compile my program, the Exe
, with libA
using a Visual Studio that uses MSCVR100
.
I will then have the following scheme:
Exe(lib A included) ---> MSVCR100
Will the program (including the static lib) be linked well against MSVC100
without any problem? Or can I expect an undefined behaviour because the header of the STL are susceptible to change between the MSVCR71
and the MSVC100
?
Upvotes: 1
Views: 1874
Reputation: 1775
I finally found the answer on MSDN...
I quote (Visual C++ change history 2003 - 2015):
To avoid run-time errors that are difficult to detect and diagnose, we recommend that you never statically link to binaries that were compiled by using different versions of the compiler. Also, when you upgrade an EXE or DLL project, make sure to upgrade the libraries that it links to. If you're using CRT (C Runtime) or STL (Standard Template Library) types, don't pass them between binaries (including DLLs) that were compiled by using different versions of the compiler.
Hence, better recompile everything with the same compiler, to be sure.
Upvotes: 3