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

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

问题描述

我应该用我的应用程序重新分发msvcrt.dll,如果某些应用程序的lib动态依赖于msvcrt.dll,请使用私有DLL?即系统的msvcrt.dll(dll地狱)可能有任何不兼容的问题吗?应用程序针对Windows Server系统。

解决方案

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



在Windows中使用C运行时有两个选项:


  1. 链接到静态运行库lib

    使用 / MT / MTd 选项到cl.exe。在这种情况下,您将不依赖msvcrt DLL,因此您不必重新分发它。在Visual Studio中,分别右键单击项目或解决方案,属性> C / C ++ - >代码生成 - >运行时库使用多线程和多线程调试。这是更简单的方法。缺点是结果可执行文件较大。


  2. 链接到动态C运行时库。

    您将使用 / MD 或cl.exe的 / MDd 选项。

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







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



如果您使用动态CRT库进行编译,则您必须必须从microsoft.com下载必需版本的运行时的可再发行包,然后执行在应用程序安装期间安装它(可能是静默的)。在VS2005之前,开发人员构建的应用程序依赖于Windows操作系统中的MSVCRT。这将给DLL的好处(小图像大小),而不会导致在应用程序安装中运送CRT DLL的要求。在Windoes 2000之前,开发人员甚至会在\Windows安装文件夹中安装一个新的MSVCRT.dll。但是,跨越许多应用程序和操作系统也共享CRT,结果是一个非常糟糕的主意。使用WinXP SP2,Windows中包含的CRT显着改变,任何依赖该CRT版本的应用程序都有可能被破坏。



此时,Microsoft告诉开发人员,Windows附带的MSVCRT.dll是操作系统的一部分,可以随时进行维修或修补。构建应用程序不支持它。因此应用程序应该使用上述方法之一。



参考文献:




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 - is a dynamic library for the Microsoft Visual C++ runtime.

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

  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.

  2. 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.


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.

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.


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.

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.

References:

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

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