146 字
1 分钟
VS Static Compilation Settings

Sometimes when you copy a program you wrote to another computer and run it, you get a prompt about a missing msxxxx.dll. This is because the target computer doesn’t have the corresponding version of the C++ runtime library installed.

At this point, you either install the C++ runtime library on the target computer, or change from dynamic compilation (without the runtime included) to static compilation (with the runtime included) at compile time. Also, dynamically compiled binaries are much smaller than statically compiled ones.

First, you must understand the relationship between the four options in Project -> Project Properties -> Configuration Properties -> C/C++ -> Code Generation -> Runtime Library:

Display NameCompile Option
Multi-threaded Debug DLL (/MDd)MD_DynamicDebug
Multi-threaded DLL (/MD)MD_DynamicRelease
Multi-threaded (/MT)MD_StaticRelease
Multi-threaded (/MTd)MD_StaticDebug

There’s a detailed explanation in MSDN: http://msdn.microsoft.com/en-us/library/2kzt1wy3(VS.80).aspx

Those with a lowercase d (like /MDd, /MTd) are Debug mode. With a D is dynamic (/MD, /MDd), with a T is static (/MT, /MTd).

VS Static Compilation Settings
https://tski.uk/blog/en/vs-static-compilation-setting/
作者
Tokisaki Galaxy
发布于
2021-04-04
许可协议
CC BY