windows 我应该用我的应用程序重新分发 msvcrt.dll 吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1073509/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Should I redistribute msvcrt.dll with my application?
提问by justadreamer
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.dll,我是否应该使用我的应用程序重新分发 msvcrt.dll 并使用私有 dll?即系统的 msvcrt.dll(dll 地狱)是否可能存在任何不兼容问题?应用程序针对 Windows Server 系统。
回答by justadreamer
msvcrt - is a dynamic library for the Microsoft Visual C++ runtime.
msvcrt - 是 Microsoft Visual C++ 运行时的动态库。
There are two options for using the C runtime in Windows:
在 Windows 中使用 C 运行时有两种选择:
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 Multithreadedand Multithreaded debugrespectively. This is the easier way. The downside is that the resulting executable is larger.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 Linkand Multithreaded Dynamic Link debugrespectively. This results in a smaller EXE, but the downside is that you must install the required MSVCRT when installing your application.
与静态运行时库链接。对 cl.exe
使用/MT
或/MTd
选项。在这种情况下,您将不依赖于 msvcrt DLL,因此您不必重新分发它。在 Visual Studio 中,右键单击项目或解决方案,属性 > C/C++->代码生成->运行时库分别使用多线程和多线程调试。这是更简单的方法。缺点是生成的可执行文件更大。与动态 C 运行时库链接。
您将使用cl.exe的/MD
或/MDd
选项。
在 Visual Studio 中,右键单击项目或解决方案,属性 > C/C++->代码生成->运行时库分别使用多线程动态链接和多线程动态链接调试。这会导致较小的 EXE,但缺点是您必须在安装应用程序时安装所需的 MSVCRT。
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.
VC++ 编译器的每个版本都附带一个版本的 C 运行时 (CRT)。Visual Studio 2005 附带了 v8 的编译器和 v8 的 CRT。v8 的实际 DLL 是 msvcrt80.dll。对于 VS2008,它是 v9,动态 CRT 是 msvcrt90.dll。但是,CRT 的更新和修补比 C/C++ 编译器更频繁。开发人员可以下载更新的 CRT,并针对它进行构建。
If you compile with the dynamic CRT library, you MUSTdownload 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.
如果使用动态 CRT 库进行编译,则必须从 microsoft.com 下载运行时必需版本的可再发行包,并在应用安装期间执行(可能是静默)安装。
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.
在 VS2005 之前,开发人员构建的应用程序依赖于 Windows 操作系统中的 MSVCRT。这将带来 DLL(小图像尺寸)的好处,同时不会产生在应用程序安装中传送 CRT DLL 的要求。在 Windoes 2000 之前,开发人员甚至会在 \Windows 安装文件夹中安装一个新的 MSVCRT.dll。但是,在许多应用程序和操作系统之间共享 CRT,结果证明是一个非常糟糕的主意。在 WinXP SP2 中,Windows 附带的 CRT 发生了重大变化,任何依赖于该版本 CRT 的应用程序都有崩溃的风险。
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.
此时,Microsoft 告诉开发人员,Windows 中包含的 MSVCRT.dll 是操作系统的一部分,可以随时提供服务或修补。不支持针对它构建应用程序。因此,应用程序应使用上述方法之一。
References:
参考:
回答by Ian Boyd
You mustship msvcrt with your application. It is not a guaranteed part of the operating system. If a particular version of Windows happensto have it, it's only because something in Windows is using it.
您必须随应用程序一起提供 msvcrt。它不是操作系统的保证部分。如果某个特定版本的 Windows碰巧拥有它,那只是因为 Windows 中的某些东西正在使用它。
Applications have broke when newer versions of Windows didn't happento contain the binaries people assumed Windows came with. Applications have broke when the user chose not to install WinFax, which meant that msvcrt wasn't installed with it.
应用程序必须打破了,当新版本的Windows没有发生含有人承担的二进制文件的Windows附带。当用户选择不安装 WinFax 时,应用程序已损坏,这意味着没有安装 msvcrt。
From Raymond Chen:
来自Raymond Chen:
Depending on what version of Windows you're running, there may be a variety of support DLLs for things that aren't formal product components, but which are merely along for the ride.
...
This problem persists today. People go scrounging around the binaries that come with Windows looking for something they can remora. And then they're surprised when those binaries change or vanish entirely.
根据您运行的 Windows 版本,可能有各种支持 DLL 用于非正式产品组件,但仅用于搭便车。
...
这个问题今天仍然存在。人们四处寻找 Windows 附带的二进制文件,寻找他们可以重温的东西。然后当这些二进制文件发生变化或完全消失时,他们会感到惊讶。
From KB326922 - Redistribution of the shared C runtime component in Visual C++:
来自KB326922 - 在 Visual C++ 中重新分发共享 C 运行时组件:
...the CRT DLL is no longer considered a system file, therefore, distribute the CRT DLL with any application that relies on it. Because it is no longer a system component, install it in your applications Program Files directory with other application-specific code. This prevents your application from using other versions of the CRT library that may be installed on the system paths.
... CRT DLL 不再被视为系统文件,因此,将 CRT DLL 与依赖它的任何应用程序一起分发。因为它不再是一个系统组件,所以将它与其他特定于应用程序的代码一起安装在您的应用程序 Program Files 目录中。这可以防止您的应用程序使用可能安装在系统路径上的其他版本的 CRT 库。
You mustship msvcrt with your application, if you link to MSVCRT.
你必须附带MSVCRT与您的应用程序,如果您链接到MSVCRT。
More
更多的
the decision was made to just give up and declare it an operating system DLL, to be used only by operating system components.
Although
MSVCRT.DLL
has been an operating system DLL for a long time, and has been documented as off-limits to applications, there are still a lot of peoplewho treat it as a C runtime delivery channel, and those programs create a lot of grief for the product team.
决定只是放弃并将其声明为操作系统 DLL,仅供操作系统组件使用。
虽然
MSVCRT.DLL
已经有很长一段时间的运行系统DLL,并已被记录为禁地应用程序,还是有很多人谁把它当作C运行时交付渠道,以及这些方案的创造了很多的悲伤产品团队。
You mustredistribute the Microsoft Visual C Runtime with your application, because Windows does not ship with any Microsoft Visual C Runtime. There might happento be a DLL called msvcrt.dll
(which is not guaranteed), it is not theMSVCRT.
您必须随应用程序重新分发 Microsoft Visual C 运行时,因为 Windows 不附带任何 Microsoft Visual C 运行时。有可能发生的是一个叫做DLL msvcrt.dll
(这是不保证的),它是不是在MSVCRT。
回答by Dudu
Chris's answer shouldn't be voted down because both are right.
克里斯的答案不应该被否决,因为两者都是正确的。
The matter is that there're two different sets of MSVCRTs. One set is the msvcrt80.dll, msvcrt90.dll, etc. which comes with Visual Studio. This is what people normally used. And they must be redistributed, as talked in other answers.
问题是有两组不同的 MSVCRT。一组是Visual Studio 自带的msvcrt80.dll、msvcrt90.dll 等。这是人们通常使用的。正如其他答案中所说,它们必须重新分配。
The other is the msvcrt.dll (with no numbers in the file name) in System32 folder, which is intended to be used ONLY by the OS itself since some time ago. And applications should never replace/reinstall it. However, some applications do link to it, for some reasons like to remove the extra dependencies to install. But be aware that it is not guaranteed to be available in future Windows version.
另一个是 System32 文件夹中的 msvcrt.dll(文件名中没有数字),从前一段时间以来,它仅供操作系统本身使用。应用程序永远不应该替换/重新安装它。但是,某些应用程序确实链接到它,出于某些原因,例如删除要安装的额外依赖项。但请注意,不能保证在未来的 Windows 版本中可用。
回答by Chris Becke
msvcrt.dll has become a defacto part of the OS distribution. On windows 98 and 95 and possibly NT4 it was possible to get OS installs without it if one went to care to strip apps like WordPad out of the installation.
msvcrt.dll 已成为操作系统分发的事实上的一部分。在 Windows 98 和 95 以及可能的 NT4 上,如果有人愿意从安装中删除像写字板这样的应用程序,则可以在没有它的情况下安装操作系统。
Given its ubiquty however, and the fact that since those OSs very few app developers have bothered to ship it, at least since windows 2000 its been an official part of the OS.
然而,鉴于它无处不在,而且由于这些操作系统很少有应用程序开发人员愿意发布它,至少从 Windows 2000 开始它是操作系统的正式组成部分。
Microsoft support has a toolthat you can use to double check what products DLLs are shipped with.
Microsoft 支持有一个工具,您可以使用它来仔细检查 DLL 随附的产品。
Perform a search like thisand you can see that msvcrt.dll vsrsion 7.0.3790.0 was part of the Windows server 2003 release.
执行像搜索这样,你可以看到,MSVCRT.DLL vsrsion 7.0.3790.0是在Windows Server 2003版本的一部分。