如何确定我的程序需要运行哪些 C++ 可再发行组件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18595008/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 22:03:41  来源:igfitidea点击:

How do I determine which c++ redistributables my program needs to run?

c++visual-c++

提问by Blub

Is it possible that I need to install both a vcredist for vs2012 AND for vs2010?

我是否可能需要同时为 vs2012 和 vs2010 安装 vcredist?

I just had an error where my app couldn't load a .dll and it suddenly started working after I did an unrelated installation, which prompted me to guess that it must have installed an older vcredist which fixed the issue. However I'm sure I'm using c++11 features.

我刚刚遇到一个错误,我的应用程序无法加载 .dll,并且在我进行了一个无关的安装后它突然开始工作,这促使我猜测它一定安装了一个较旧的 vcredist 来解决这个问题。但是我确定我正在使用 c++11 功能。

采纳答案by Martin Schlott

Deployment is a job on its own. And I hate it, I hate the way you have to write installations on Windows. …So that feel better now…

部署本身就是一项工作。我讨厌它,我讨厌你必须在 Windows 上编写安装的方式。……所以现在感觉好多了……

You only need one vcredist. The one the linker decided to link your program to. If you have the "Windows SDK's" installed you will find the actual redist in:

您只需要一个 vcredist。链接器决定将您的程序链接到的那个。如果您安装了“Windows SDK”,您将在以下位置找到实际的 redist:

C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\vcredist_x86

If you install all updates including the not important ones, Microsoft will update your redist in that folder!

如果您安装所有更新,包括不重要的更新,Microsoft 将更新您在该文件夹中的 redist!

Maybe you have an executable, which do not want to run, you need the dependency walker. A tool, so usefully that Microsoft had to remove it from the Visual Studio. Download the program and open your exe in it. You do not need to understand what really happen. As long as no Dialog comes up during opening, everything is okay, even if there are exclamation marks in the bottom window. If a Dialog comes up with something like "Could not resolve" than look in the bottom window. Usually there is now in the lower window something like "msvcr.dll" or "msvcr100.dll" or "msvcr110.dll". If it includes an "d" before the extension like "msvcr100d.dll" the executable was compiled in debug mode and your journey ends on a system without installed compiler. If not, the name is telling you which vcredist you need:

也许你有一个不想运行的可执行文件,你需要依赖walker。一个非常有用的工具,以至于微软不得不将它从 Visual Studio 中删除。下载程序并在其中打开您的 exe。你不需要了解真正发生了什么。只要在打开过程中没有出现 Dialog 就一切正常,即使底部窗口中有感叹号。如果对话框出现“无法解决”之类的内容,请查看底部窗口。现在通常在较低的窗口中有类似“msvcr.dll”或“msvcr100.dll”或“msvcr110.dll”的东西。如果它在像“msvcr100d.dll”这样的扩展名之前包含一个“d”,则可执行文件在调试模式下编译,您的旅程将在没有安装编译器的系统上结束。如果不,

msvcr100 = VS 2010 redist (32bit)(64bit)

msvcr100 = VS 2010 redist (32bit) (64bit)

msvcr110 = VS 2012 redist (32/64bit?)

msvcr110 = VS 2012 redist 32/64位?)

sometimes it is not msvcr but it always starts with "ms". Of course the program will tell you every dll which is missing, not only microsofts and which command in the dll is used. This is sometimes extremely useful. You have to do that with every dll in the folder of your executable as they can also have unresolveable dependencies.
Back to your first question. Your program can only link to msvcr100 or msvcr110, not to both, that is the reason you only need one vcredist per executable. As mentioned in a commentary, A third party DLL can be guilty of using a different msvcp version. So yeah, you have to search all DLL's you use and you have to install both vcredist some times.

有时它不是 msvcr 但它总是以“ms”开头。当然,该程序会告诉您缺少的每个 dll,而不仅仅是 microsofts 以及使用了 dll 中的哪个命令。这有时非常有用。您必须对可执行文件文件夹中的每个 dll 执行此操作,因为它们也可能具有无法解析的依赖项。
回到你的第一个问题。您的程序只能链接到 msvcr100 或 msvcr110,不能同时链接到两者,这就是每个可执行文件只需要一个 vcredist 的原因。正如评论中提到的,第三方 DLL 可能因使用不同的 msvcp 版本而感到内疚。所以是的,您必须搜索您使用的所有 DLL,并且有时必须安装两个 vcredist。

PS: There are always at least two of them, msvcr and msvcp.

PS:总是至少有两个,msvcr 和 msvcp。

回答by Valentas

I solved this problem as follows (on Windows 7):

我按如下方式解决了这个问题(在 Windows 7 上):

  1. I tried to load the library and it failed showing "The application failed to start because its side by side information is incorrect."
  2. I opened "Computer management" window: Start -> right click on Computer->Manage.
  3. In the "Computer management" window I selected "Event Viewer"->"Windows logs"->"Application".
  4. The log corresponding to the error said that a DLL for a certain version of Microsoft.VC90.CRT was not found. In my case the version was 9.0.30729.6161 and the search for it in Google revealed I needed to install an "unusual" version of redistributables from here.
  1. 我尝试加载库,但失败显示“应用程序无法启动,因为其并排信息不正确。”
  2. 我打开了“计算机管理”窗口:开始-> 右键单击​​计算机-> 管理。
  3. 在“计算机管理”窗口中,我选择了“事件查看器”->“Windows 日志”->“应用程序”。
  4. 错误对应的日志说找不到某个版本的Microsoft.VC90.CRT的DLL。在我的情况下,版本是 9.0.30729.6161 并且在 Google 中搜索它显示我需要从这里安装一个“不寻常”的可再发行版本。

The dependency walker did not help for me (it only confused me by reporting unnecessary dependencies).

依赖遍历器对我没有帮助(它只会报告不必要的依赖使我感到困惑)。

回答by Luke

If you want to know which runtimes are needed, you can try using the "Dependencies" tool from lucasg on github (https://github.com/lucasg/Dependencies) which works on modern systems like win10.

如果您想知道需要哪些运行时,您可以尝试使用 github 上 lucasg 的“Dependencies”工具(https://github.com/lucasg/Dependencies),该工具适用于 win10等现代系统。

You'll just have to look for MsVcR##.dllo VcRuntime###.dll(where # stands for a digit) in the dependency tree..

您只需要在依赖关系树中查找MsVcR##.dllo VcRuntime###.dll(其中 # 代表数字)。

HTH

HTH

PS: The old-and-faithful "dependency walker" we've been using for years seems to be unable to handle the way newer OS handle delayed dependencies, marking them as "missing", while they are not missing, just delay loaded in a way it doesn't know...

PS:我们多年来一直使用的古老而忠实的“依赖行走器”似乎无法处理较新的操作系统处理延迟依赖的方式,将它们标记为“缺失”,而它们并没有缺失,只是延迟加载一种它不知道的方式......

回答by David Ching

If your OS is Vista or later (not XP), use the built-in SxStrace.exe to generate a log of which DLL's are being loaded and what module requires them. It will clearly show you if multiple CRT DLL versions are being loaded, and for what DLL's (3rd party or no).

如果您的操作系统是 Vista 或更高版本(不是 XP),请使用内置的 SxStrace.exe 生成正在加载哪些 DLL 以及哪些模块需要它们的日志。它会清楚地向您显示是否正在加载多个 CRT DLL 版本,以及加载哪些 DLL(第三方或没有)。

The VS2012 redistributable is put into, e.g. "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\redist".

将 VS2012 可再发行组件放入例如“C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\redist”。

-- David

- 大卫