VS的ML、MT和MD

运行时库是程序在运行时所需要的库文件,通常运行时库是以LIB或DLL形式提供的。对于C,C run-time library里面含有初始化代码,还有错误处理代码(例如divide by zero处理)。你写的程序可以没有math库,程序照样运行,只是不能处理复杂的数学运算,不过如果没有了C run-time库,main()就不会被调用,exit()也不能被响应。因为C run-time library包含了C程序运行的最基本和最常用的函数。到了 C++ 世界里,有另外一个概念:Standard C++ Library,它包括了C run-time library 和 STL。

Visual C++提供的多线程运行时库又分为静态链接库(MT、MTd)和动态链接库(MD、MDd)两类,而每一类运行时库又可再分为debug版和release版,因此Visual C++共提供了6个运行时库。如下表:

Reusable LibrarySwitchLibraryMacro(s) Defined
Single Threaded /ML LIBC (none)
Static MultiThread /MT LIBCMT _MT
Dynamic Link (DLL) /MD MSVCRT _MT and _DLL
Debug Single Threaded /MLd LIBCD _DEBUG
Debug Static MultiThread /MTd LIBCMTD _DEBUG and _MT
Debug Dynamic Link (DLL) /MDd MSVCRTD _DEBUG, _MT, and _DLL


注:从Visual C++ 2005开始,libcp.lib和libcpd.lib(老的/ML和/MLd选项)已经被移除。通过/MT和/MTd使用libcpmt.lib和libcpmtd.lib取代。

 /MT和/MTd表示采用多线程CRT库的静态lib版本。该选项会在编译时将运行时库以静态lib的形式完全嵌入。该选项生成的可执行文件运行时不需要运行时库dll的参加,会获得轻微的性能提升,但最终生成的二进制代码因链入庞大的运行时库实现而变得非常臃肿。当某项目以静态链接库的形式嵌入到多个项目,则可能造成运行时库的内存管理有多份,最终将导致致命的“Invalid Address specified to RtlValidateHeap”问题。

/MD和/MDd表示采用多线程CRT库的动态dll版本,会使应用程序使用运行时库特定版本的多线程DLL。链接时将按照传统VC链接dll的方式将运行时库MSVCRxx.DLL的导入库MSVCRT.lib链接,在运行时要求安装了相应版本的VC运行时库可再发行组件包(当然把这些运行时库dll放在应用程序目录下也是可以的)。 因/MD和/MDd方式不会将运行时库链接到可执行文件内部,可有效减少可执行文件尺寸。当多项目以MD方式运作时,其内部会采用同一个堆,内存管理将被简化,跨模块内存管理问题也能得到缓解。



.m-md-n1 { margin: -0.25rem !important; } .m-md-n2 { margin: -0.5rem !important; } .m-md-n3 { margin: -1rem !important; } .m-md-n4 { margin: -1.5rem !important; } .m-md-n5 { margin: -3rem !important; } .m-md-n6 { margin: -5rem !important; } .mx-md-n1 { margin-right: -0.25rem !important; margin-left: -0.25rem !important; } .mx-md-n2 { margin-right: -0.5rem !important; margin-left: -0.5rem !important; } .mx-md-n3 { margin-right: -1rem !important; margin-left: -1rem !important; } .mx-md-n4 { margin-right: -1.5rem !important; margin-left: -1.5rem !important; } .mx-md-n5 { margin-right: -3rem !important; margin-left: -3rem !important; } .mx-md-n6 { margin-right: -5rem !important; margin-left: -5rem !important; } .my-md-n1 { margin-top: -0.25rem !important; margin-bottom: -0.25rem !important; } .my-md-n2 { margin-top: -0.5rem !important; margin-bottom: -0.5rem !important; } .my-md-n3 { margin-top: -1rem !important; margin-bottom: -1rem !important; } .my-md-n4 { margin-top: -1.5rem !important; margin-bottom: -1.5rem !important; } .my-md-n5 { margin-top: -3rem !important; margin-bottom: -3rem !important; } .my-md-n6 { margin-top: -5rem !important; margin-bottom: -5rem !important; } .mt-md-n1 { margin-top: -0.25rem !important; } .mt-md-n2 { margin-top: -0.5rem !important; } .mt-md-n3 { margin-top: -1rem !important; } .mt-md-n4 { margin-top: -1.5rem !important; } .mt-md-n5 { margin-top: -3rem !important; } .mt-md-n6 { margin-top: -5rem !important; } .me-md-n1 { margin-right: -0.25rem !important; } .me-md-n2 { margin-right: -0.5rem !important; } .me-md-n3 { margin-right: -1rem !important; } .me-md-n4 { margin-right: -1.5rem !important; } .me-md-n5 { margin-right: -3rem !important; } .me-md-n6 { mar
最新发布
04-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值