Understanding of /MT, /MTd, /MD, /MDd options when compiling static and dynamic link libraries for VC

Most people know that in the Windows development process, to achieve code reuse, it will be packaged into an interface, and then packaged into a library form, which has a static library and a dynamic library. The advantage of the dynamic library is that it can reduce the size of the application, and only need to replace the DLL when upgrading, and truly modularization.

But this static library or dynamic library actually has two ways when using the C/C++ runtime library. One is to link the multi-threaded static libraries libcmt.lib and libcpmt.lib, use the /MT option; the other is to link more The thread dynamic link libraries MSVCRXX.DLL and MSVCPXX.DLL use the /MD option. The small d behind is actually the meaning of the debug version, so in fact only the difference between MT and MD.

Explain here that a library is like a module of a product, and it may depend on other modules to work. For example, if you buy an electronic product without a battery, you need to dynamically link to the battery. If you buy a battery, it is equivalent to a statically linked battery.

That is to say: not only the library linked by the application has static and dynamic points, but the library itself also links to the system runtime library (this is inevitable because the C/C++ system library function is called), and different link methods lead to This difference, in general, mt is larger than the static library of the md type.

When creating a static library or dynamic link library using VC, set it from the project's property page, as shown below:

Reference link:

Finally understand what is the content library, and libcmt msvcrt and other c / c ++ runtime

Intelligent Recommendation

Some links and problems between MTD/MT/MDD/MD and LIB/DLL

Where do you start talking about this topic? The blogger Xiaobai one, recently debugged the program (WIN-MSVC) and did not understand some basic problems, in line with the principle of meeting the pro...

Qt sets the runtime library MT, MTd, MD, MDd in pro

Qt sets the runtime library MT, MTd, MD, MDd in pro, focusing onQMAKE_CFLAGS Multi-threaded debugging Dll (/MDd) corresponds to MD_DynamicDebug Multi-threaded Dll (/MD) corresponds to MD_DynamicReleas...

About the pit of the VS compilation connection. (/ MT) (/ MTD) (/ MD) (/ MDD)

  Microsoft gives the program that the runtime used by the default is (/ MD) (/ MDD) is a dynamic runtime. Sometimes it contains a third-party library, a link is a bunch of error, then run the li...

CMAKE Set MSVC Engineering MT/MTD/MD/MDD

Articles directory 0. Foreword 1. How to set up 1.1 Cmakelists code 1.2 Point 1: Policy 1.3 Key points 2: set_proprty 0. Foreword existMSVCEngineeringRight-click-> Properties,turn upConfiguration a...

libcef-compile operation mode-MTD/MT-MDD/MD

Article Directory 1. Open the project 2. Modify options 3. Verification test In an embedded running environment, most of the host software may use the MD mode to load and run the C++ runtime library. ...

More Recommendation

How to compile CEF static library (/ MT) as dynamic libraries (/ MD)

Children's shoes with CEF should know that using the VS compilation CEF source code generated is the libcef_dll_wrapper.lib static library, and the run library is multi-thread (/ MT), which cannot be ...

The difference between VC linker options / MT and / MD of

If there is a dll below this function, you must use the / MD or / MDd Options link, you can not use / MT or / MTd: Otherwise, this module if people have done so, run the program will crash:...

The difference between multithreading (/MT), multithreaded debugging (/MTd), multithreaded DLL (/MD), multithreaded debugging DLL (/MDd) in VS

A language development environment often comes with a language library, which is a wrapper around the operating system's API. We also call these language libraries a runtime library. For the MSVC runt...

[VS] release library lib/dll with running environment (/MT, /MTd, /MD, /MDd)

Library Release principle: 1, xxx_x86.lib, xxx_x64.lib xxx_x86.dll, xxx_x64.dll --- with operating environment (debug / non-debug)   The language development environment is often accompanied by a...

C/C++ runtime library in VS project properties: MT, MTd, MD, MDd

original: C/C++ runtime library in VS project properties: MT, MTd, MD, MDd The article is reproduced from:      In each version of the compiler, we can configure the type of C and C++ runtim...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top