我应该用我的应用程序重新分发 msvcrt.dll 吗? [英] Should I redistribute msvcrt.dll with my application?

查看:17
本文介绍了我应该用我的应用程序重新分发 msvcrt.dll 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果应用程序的某些库动态依赖于 msvcrt.dll,我是否应该使用我的应用程序重新分发 msvcrt.dll 并使用私有 dll?IE.系统的 msvcrt.dll(dll 地狱)是否可能存在任何不兼容问题?应用程序针对 Windows Server 系统.

Should I redistribute msvcrt.dll with my application and use the private dll if some of the application's libs dynamically depend on msvcrt.dll? I.e. are any incompatibility issues possible with the system's msvcrt.dll (dll hell)? Application is targeted for Windows Server systems.

推荐答案

msvcrt - 是 Microsoft Visual C++ 运行时的动态库.

msvcrt - is a dynamic library for the Microsoft Visual C++ runtime.

在 Windows 中使用 C 运行时有两种选择:

There are two options for using the C runtime in Windows:

  1. 链接到静态运行时库.
    对 cl.exe 使用 /MT/MTd 选项.在这种情况下,您将不依赖于 msvcrt DLL,因此您不必重新分发它.在 Visual Studio 中,右键单击项目或解决方案,属性 > C/C++->代码生成->运行时库分别使用 MultithreadedMultithreaded debug.这是更简单的方法.缺点是生成的可执行文件更大.

  1. link with static runtime libs.
    Use either the /MT or the /MTd option to cl.exe. In this case, you will have no dependency on the msvcrt DLL, and therefore you will not have to redistribute it. In Visual Studio, right click on the Project or Solution, Properties > C/C++->Code Generation->Runtime library use Multithreaded and Multithreaded debug respectively. This is the easier way. The downside is that the resulting executable is larger.

链接到动态 C 运行时库.
您将在 cl.exe 中使用 /MD/MDd 选项.
在 Visual Studio 中,右键单击项目或解决方案,属性 > C/C++->代码生成->运行时库分别使用多线程动态链接多线程动态链接调试.这会导致较小的 EXE,但缺点是在安装应用程序时必须安装所需的 MSVCRT.

link with the dynamic C Runtime library.
You will use either the /MD or the /MDd option to cl.exe.
In Visual Studio, right click on the Project or Solution, Properties > C/C++->Code Generation->Runtime library use Multithreaded Dynamic Link and Multithreaded Dynamic Link debug respectively. This results in a smaller EXE, but the downside is that you must install the required MSVCRT when installing your application.

<小时>

VC++ 编译器的每个版本都附带一个 C 运行时 (CRT) 版本.Visual Studio 2005 附带了 v8 的编译器和 v8 的 CRT.v8 的实际 DLL 是 msvcrt80.dll.对于 VS2008,它是 v9,动态 CRT 是 msvcrt90.dll.但是,CRT 的更新和修补比 C/C++ 编译器更频繁.开发人员可以下载更新的 CRT,然后根据它进行构建.


Each release of the VC++ compiler ships with a version of the C runtime (CRT). Visual Studio 2005 shipped with v8 of the compiler, and v8 of the CRT. The actual DLL for v8 was msvcrt80.dll. For VS2008, it was v9, and the dynamic CRT was msvcrt90.dll. But, the CRT is updated and patched more frequently than is the C/C++ compiler. A developer can download an updated CRT, and build against that.

如果您使用动态 CRT 库进行编译,则必须从 microsoft.com 下载运行时必要版本的可再发行包,并在应用安装期间执行(可能是静默)安装.

If you compile with the dynamic CRT library, you MUST download a redistributable package for the necessary version of the runtime from microsoft.com and perform a (potentially silent) install of it during your app install.

在 VS2005 之前,开发人员构建的应用依赖于 Windows 操作系统中的 MSVCRT.这将带来 DLL(小图像尺寸)的好处,同时不会产生在应用程序安装中传送 CRT DLL 的要求.在 Windoes 2000 之前,开发人员甚至会在 Windows 安装文件夹中安装一个新的 MSVCRT.dll.但是,在许多应用程序和操作系统之间共享 CRT,结果证明是一个非常糟糕的主意.使用 WinXP SP2,Windows 附带的 CRT 发生了重大变化,任何依赖于该版本 CRT 的应用程序都有崩溃的风险.

Prior to VS2005, developers built apps to depend on the MSVCRT that was in the Windows operating system. This would give the benefit of the DLL (small image size) while not incurring the requirement of shipping the CRT DLL in the application install. Prior to Windoes 2000, developers would even install a new MSVCRT.dll in the Windows installation folder. But, sharing the CRT across many apps and the OS too, turned out to be a really bad idea. With WinXP SP2, the CRT included with Windows changed significantly, and any apps that depended on that version of the CRT were at risk of breaking.

此时,Microsoft 告诉开发人员,Windows 中包含的 MSVCRT.dll 是操作系统的一部分,可以随时提供服务或修补.不支持针对它构建应用程序.因此,应用程序应使用上述方法之一.

At this point Microsoft tells developers that the MSVCRT.dll that is included with Windows is part of the OS, and may be serviced or patched at any time. It is not supported to build an app against it. Therefore applications should use one of the methods above.

参考文献:

这篇关于我应该用我的应用程序重新分发 msvcrt.dll 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆