gpt4 book ai didi

c++ - VS 2005 C++ 项目中的 msvcr90.dll 依赖项

转载 作者:可可西里 更新时间:2023-11-01 18:28:55 25 4
gpt4 key购买 nike

我在 VS 2005 中为 native Win32/非托管 C++ 创建了一个 DLL 项目,将其命名为 myProj.dll。它依赖于第 3 方商业 DLL,后者又依赖于 msvcr90.dll(我假设它是从 VS 2008 项目构建的)。我将其命名为 thirdParty.dll。

我的 DLL 项目在 VS2005 中构建得很好。我构建了一个链接到 myProj.lib 的测试应用程序(同样是 VS 2005 Win32 C++)。 (顺便说一句,根据 .lib 的小尺寸以及在运行时应用程序必须找到 myProj.dll 的事实来判断,我猜测 .lib 只是调用的包装器加载实际 DLL 的 loadLibrary();是否接近?)

我的问题是,在运行时,测试应用无法找到 msvcr90.dll(也不是 msvcp90.dll),依赖于 thirdParty.dll。

我已经安装了 Microsoft 的 redist 包,因此在 c:\WINDOWS\WinSxS\x86_Microsoft.VC90.CRT_... 中安装了所有标准 (9.0) C++ 库。更重要的是,如果我将 dependency walker 指向 thirdParty.dll,它会愉快地解析对该位置的引用。

但是,如果我将 depends.exe 指向我的测试应用程序 (.exe) 或 myProj.dll,则找不到 msvcr90.dll 和 msvcp90.dll。

我猜我需要在 VS2005 中配置一些东西,以便 .exe 或 myProj.dll 知道 9.0 版本的标准 C++ 库的位置(大概是 redist 包将它们安装在 C:\WINDOWS\WinSxS),但我似乎无法弄清楚它是什么。我走在正确的轨道上吗?

我注意到,如果我只是将 msvc*90.dll 文件复制到我的应用程序目录,则依赖关系已解决,但我会收到有关不正确加载 std c++ DLL 等的运行时错误。

非常感谢。

最佳答案

对我来说,这看起来像一个“并排程序集”问题。

据我所知,Microsoft 试图阻止过去几年的 DLL Hell 问题,引入了“并行程序集”的概念。

简而言之,这意味着您的应用程序需要告诉 Windows 它设计用于使用哪个版本的 CRT。安装应用程序时,Windows 将确保您的应用程序获得这些 DLL 文件的自己的私有(private)拷贝。

要使其全部正常工作,您需要将应用程序的 DLL 依赖项嵌入到应用程序 Manifest 文件中,并使用 Manifest Tool 将其附加到项目,Input应用程序项目设置的输出部分。

这里的示例是我用于 Zeus for Windows 的 list 开发环境:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
name="Xidicone.Windows.Zeus for Windows"
version="3.9.6.69"
processorArchitecture="X86"
type="win32" />

<description>Zeus for Windows</description>

<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.VC80.CRT"
version="8.0.50608.0"
processorArchitecture="x86"
publicKeyToken="1fc8b3b9a1e18e3b" />
</dependentAssembly>
</dependency>

<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*" />
</dependentAssembly>
</dependency>
</assembly>

最后,如果您打算制作安装程序,则需要将这些 DLL 文件的相同版本添加到应用程序安装程序中,或者让您的安装程序运行 Microsoft CRT 可再发行安装程序。

FWIW 我只是在用户报告 Zeus 时才发现这件事由于缺少 MSVCRT 运行时 DLL 文件而不再在 Windows XP 上运行,但 Zeus 10 多年来一直运行良好,而无需附带 MSVCRT 运行时 DLL 文件。

关于c++ - VS 2005 C++ 项目中的 msvcr90.dll 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/332473/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com