athos athos - 1 month ago 4
C++ Question

Visual Studio C++: will using /MT causes run-time library be linked in multiple times?

I understand that

compiler option causes the application to use the multithread, static version of the run-time library.

Suppose my solution consists main project
as a Win32 console application, and a
compiled as static library, both using
. Will the CRT be linked into the final
twice -- once by the
, once via
as a static libary?


The CRT will only be linked in once. Both the main project and the PrjLib library will link to the same static CRT, as long as both the project and library are compiled into one binary.

Where problems come from are when mixing a module that uses a static CRT with one that uses the DLL CRT in one binary, or when using multiple binaries (an executable and a DLL) that both use the static library. In those cases you'll get two copies of the CRT loaded, which can cause problems.