CRT Library Features

转载自: https://msdn.microsoft.com/en-us/library/abx4dbyh(v=vs.120).aspx


This topic discusses the various .lib files that comprise the C run-time libraries as well as their associated compiler options and preprocessor directives.

C Run-Time Libraries (CRT)

The following libraries contain the C run-time library functions.

C run-time library (without iostream or standard C++ library)

Associated DLL

Characteristics

Option

Preprocessor directives

libcmt.lib

None, static link.

Multithreaded, static link

/MT

_MT

msvcrt.lib

msvcr120.dll

Multithreaded, dynamic link (import library for MSVCR120.DLL). Be aware that if you use the Standard C++ Library, your program will need MSVCP120.DLL to run.

/MD

_MT, _DLL

libcmtd.lib

None, static link

Multithreaded, static link (debug)

/MTd

_DEBUG, _MT

msvcrtd.lib

msvcr120d.dll

Multithreaded, dynamic link (import library for MSVCR120D.DLL) (debug).

/MDd

_DEBUG, _MT, _DLL

msvcmrt.lib

None, static link

C Runtime static library. Used for mixed managed/native code.

/clr

 

msvcurt.lib

None, static link

C Runtime static library compiled as 100% pure MSIL code. All code complies with the ECMA URT spec for MSIL.

/clr:pure

 

Note Note

The single-threaded CRT (libc.lib, libcd.lib) (formerly the /ML or /MLd options) is no longer available. Instead, use the multithreaded CRT. See Multithreaded Libraries Performance.

If you link your program from the command line without a compiler option that specifies a C run-time library, the linker will use LIBCMT.LIB. This is different from previous versions of Visual C++ which used LIBC.LIB, the single-threaded library, instead.

Using the statically linked CRT implies that any state information saved by the C runtime library will be local to that instance of the CRT. For example, if you use strtok, _strtok_l, wcstok, _wcstok_l, _mbstok, _mbstok_l when using a statically linked CRT, the position of the strtok parser is unrelated to the strtok state used in code in the same process (but in a different DLL or EXE) that is linked to another instance of the static CRT. In contrast, the dynamically linked CRT shares state for all code within a process that is dynamically linked to the CRT. This concern does not apply if you use the new more secure versions of these functions; for example, strtok_s does not have this problem.

Because a DLL built by linking to a static CRT will have its own CRT state, it is not recommended to link statically to the CRT in a DLL unless the consequences of this are specifically desired and understood. For example, if you call _set_se_translator in an executable that loads the DLL linked to its own static CRT, any hardware exceptions generated by the code in the DLL will not be caught by the translator, but hardware exceptions generated by code in the main executable will be caught.

If you are using the /clr compiler switch, your code will be linked with a static library, msvcmrt.lib. The static library provides a proxy between your managed code and the native CRT. You cannot use the statically linked CRT ( /MT or /MTd options) with /clr. Use the dynamically-linked libraries (/MD or /MDd) instead.

If you are using the /clr:pure compiler switch, your code will be linked with the static library msvcurt.lib. As with /clr, you cannot link with the statically linked library.

For more information on using the CRT with /clr, see Mixed (Native and Managed) Assemblies; for /clr:pure, see Pure and Verifiable Code (C++/CLI).

To build a debug version of your application, the _DEBUG flag must be defined and the application must be linked with a debug version of one of these libraries. For more information about using the debug versions of the library files, see CRT Debugging Techniques.

This version of Visual C++ is not conformant with the C99 standard.

Standard C++ Library

Standard C++ Library

Characteristics

Option

Preprocessor directives

LIBCPMT.LIB

Multithreaded, static link

/MT

_MT

MSVCPRT.LIB

Multithreaded, dynamic link (import library for MSVCP120.dll)

/MD

_MT, _DLL

LIBCPMTD.LIB

Multithreaded, static link

/MTd

_DEBUG, _MT

MSVCPRTD.LIB

Multithreaded, dynamic link (import library for MSVCP120D.DLL)

/MDd

_DEBUG, _MT, _DLL

Note   LIBCP.LIB and LIBCPD.LIB (via the old /ML and /MLd options) have been removed. Use LIBCPMT.LIB and LIBCPMTD.LIB instead via the /MT and /MTd options.

When you build a release version of your project, one of the basic C run-time libraries (LIBCMT.LIB, MSVCMRT.LIB, MSVCRT.LIB) is linked by default, depending on the compiler option you choose (multithreaded, DLL, /clr). If you include one of the C++ Standard Library Header Files in your code, a Standard C++ Library will be linked in automatically by Visual C++ at compile time. For example:

#include <ios> 

To change which basic C run-time library is linked in Visual Studio, open the property pages for your project. Open the Configuration PropertiesC/C++Code Generation page and change the Runtime Library setting. To change the Common Language Runtime library, open the property pages for your project. Open the Configuration PropertiesC/C++General page and then change the Common Language RunTime Support setting.

What is the difference between msvcrt.dll and msvcr120.dll?

The msvcrt.dll is now a "known DLL," meaning that it is a system component owned and built by Windows. It is intended for future use only by system-level components.

What problems exist if an application uses both msvcrt.dll and msvcr120.dll?

If you have a .lib or .obj file that needs to link to msvcrt.lib, then you should not have to recompile it to work with the new msvcrt.lib in Visual C++. The .lib or .obj file may rely on the sizes, field offsets, or member function names of various CRT classes or variables, and those should all still exist in a compatible way. When you relink against msvcrt.lib, your final EXE and DLL image will now have a dependency on msvcr120.dll instead of msvcrt.dll.

If you have more than one DLL or EXE, then you may have more than one CRT, whether or not you are using different versions of Visual C++. For example, statically linking the CRT into multiple DLLs can present the same problem. Developers encountering this problem with static CRTs have been instructed to compile with /MD to use the CRT DLL. Now that the CRT DLL has been renamed to msvcr120.dll, applications may have some components linked to msvcrt.dll and others to msvcr120.dll. If your DLLs pass CRT resources across the msvcrt.dll and msvcr120.dll boundary, you will encounter issues with mismatched CRTs and need to recompile your project with Visual C++.

If your program is using more than one version of the CRT, some care is needed when passing certain CRT objects (such as file handles, locales and environment variables) across DLL boundaries. For more information on the issues involved and how to resolve them, see Potential Errors Passing CRT Objects Across DLL Boundaries.


■■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■ 首先说明: 1、绿色无毒,亲测可用,放心使用,分享万岁 2、找了好久,终于可用 3、secureCRT_6.7.4.354 可以自己到官网下载 也可以用我下载的(无毒) 4、注册机无毒(之前我找的注册机,被查杀了。 但这个没的哦。大家可以去在杀毒。 提供一个在线杀毒网址(里面有很多杀毒软件) http://r.virscan.org/report/5f784624d930eb5b75cbcc7112876edc.html (这个是我杀毒留下的日志,可以查看一下,是不是没有毒哦) http://www.virscan.org/(自己上传注册机,杀毒就可以了) --------------------------------------- 文件名称 : secureCRT_6.7.4.354.exe (本站不提供任何文件的下载服务) 文件大小 : 16296112 byte 文件类型 : PE32 executable for MS Windows (GUI) Intel 80386 32-bit MD5 : dba0a9f69dd227e147beec161d29785a SHA1 : 5e67b0759c598d382fba9430324f140150ef53af --------------------------------------- ■■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■ 测试版本:SecureCRT 6.7.4 软件首页:SecureCRT (non-integrated) 下载地址:http://www.vandyke.com/download/securecrt/download.html 帐号密码:zhanqi0404@163.com/zhanqi0404 注册机:SecureCRT.v.6.X-kg ■■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■ 注册步骤: 1:安装 SecureCRT 2:复制 SecureCRT.6.X.Keygen.exe 到 SecureCRT 安装目录 3:启动注册机,输入注册信息,随便输入用户和公司,点击 Patch 4:点击 Generate,生成序列号跟 Licence 5:启动 SecureCRT,按照步骤输入注册信息 6:完成注册 7、”features:(leave blank if license has no features“这个地方不用填写,否则完成不了 ■■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■ 备注说明: 我安装时候,缺水一个mfc100u.dll文件,搜索后再站长网(admin5.com)下载的 其它网站不放心哦。 没发现其它问题。 2013.8.14 ■■■■■■■■■■■■■■■■■■■■ ■■■■■■■■■■■■■■■■■■■■
CRT Debugging Library是Visual Studio自带的内存泄漏检测库,它可以帮助您检测程序中的内存泄漏问题。以下是使用CRT Debugging Library的简单步骤: 1. 在Visual Studio中打开您的项目,然后在“解决方案资源管理器”中右键单击您的项目,选择“属性”。 2. 在“属性页”中选择“配置属性” -> “C/C++” -> “代码生成”,将“运行库”设置为“调试多线程 (/MTd)”或“调试DLL多线程 (/MDd)”。 3. 在“属性页”中选择“配置属性” -> “链接器” -> “常规”,将“调试信息格式”设置为“程序数据库 (/Zi)”或“程序数据库 (/ZI)”。 4. 在“属性页”中选择“配置属性” -> “链接器” -> “调试”,将“生成调试信息”设置为“是 (/DEBUG)”。 5. 在您的代码中,包含头文件crtdbg.h,并在程序启动时调用_CrtSetDbgFlag函数,如下所示: ``` #include <crtdbg.h> int main() { _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); // your code here return 0; } ``` _CrtSetDbgFlag函数可以设置内存泄漏检测标志,_CRTDBG_ALLOC_MEM_DF表示在内存分配时进行检查,_CRTDBG_LEAK_CHECK_DF表示在程序退出时检查内存泄漏。 6. 运行程序,当程序退出时,CRT Debugging Library会将内存泄漏信息输出到“输出”窗口中。 使用CRT Debugging Library可以帮助您检测程序中的内存泄漏问题,但也会对程序的性能产生一定的影响,建议在开发过程中使用,在发布版本时取消内存泄漏检测。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值