VS 2005 C ++项目中的msvcr90.dll依赖关系 [英] msvcr90.dll dependency in VS 2005 C++ project

查看:124
本文介绍了VS 2005 C ++项目中的msvcr90.dll依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS 2005中为本机Win32 /非托管C ++创建了一个DLL项目,称为myProj.dll。这取决于第三方商业DLL,而依赖于msvcr90.dll(我认为它是从VS 2008项目构建的)。我将其称为thirdParty.dll。



我的DLL项目在VS2005中构建得很好。我已经建立了一个测试应用程序(再次,VS 2005 Win32 C ++)链接到myProj.lib。 (除此之外,由.lib的小尺寸判断,并且在运行时,应用程序必须找到myProj.dll,我猜测.lib只是一个调用的包装器我的问题是,在运行时,测试应用程序无法找到msvcr90.dll(也不是msvcp90) .dll),这是依赖于第三方的DLL。



我已经安装了微软的redist软件包,所以所有的std(9.0)C ++库c:\WINDOWS\WinSxS\x86_Microsoft.VC90.CRT _...。更重要的是,如果我将依赖步骤指向thirdParty.dll,它可以很快地解析对该位置的引用。



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



我猜想有一些我需要在VS2005中进行配置, .exe或myProj.dll都知道9.0版本的std C ++库的位置(推测redist程序包安装在C:\WINDOWS\WinSxS中),但我似乎无法弄清楚它是什么是。我在正确的轨道上?



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



提前非常感谢。

解决方案

这对我来说看起来像是一个并排组件。



从我可以告诉我,微软试图阻止过去几年的DLLHell 问题引入了一个并排组件的概念。



在一个坚果壳中,这意味着您的应用程序需要告诉 Windows 其设计用于的 CRT 版本。当安装应用程序时,Windows将确保您的应用程序获得自己的这些DLL文件的私有副本。



为了使其全部工作,您需要将应用程序的DLL依赖项嵌入应用程序 Manifest 文件,并使用应用程序项目设置的清单工具输入和输出部分将其附加到项目中。



此处的示例是我用于 Zeus for Windows 的清单IDE:

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

< description> Zeus for Windows< / description>

<依赖关系>
< dependentAssembly>
< assemblyIdentity
type =win32
name =Microsoft.VC80.CRT
version =8.0.50608.0
processorArchitecture =x86
publicKeyToken =1fc8b3b9a1e18e3b/>
< / dependentAssembly>
< / 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当用户报告宙斯由于缺少MSVCRT运行时DLL文件而不再在Windows XP上运行,而宙斯已经工作了十多年,一直没有一次运送一个MSVCRT运行时DLL文件。


I've created a DLL project in VS 2005 for native Win32/unmanaged C++, call it myProj.dll. It depends on a 3rd-party commercial DLL that in turn depends on msvcr90.dll (I assume it was built from a VS 2008 project). I'll call it thirdParty.dll.

My DLL project builds just fine in VS2005. I've built a test app (again, VS 2005 Win32 C++) that links to myProj.lib. (As an aside, judging by the small size of the .lib, and by the fact that, at run-time, the app must locate myProj.dll, I'm guessing that the .lib is just a wrapper for a call to loadLibrary() that loads the actual DLL; is that close?)

My problem is that, at run-time, the test app cannot locate msvcr90.dll (nor msvcp90.dll), the dependency on which stems from the thirdParty.dll.

I've installed Microsoft's redist package, and so have all the std (9.0) C++ libraries in c:\WINDOWS\WinSxS\x86_Microsoft.VC90.CRT_... . What's more, if I point the dependency walker at thirdParty.dll, it happily resolves the references to that location.

But, if I point depends.exe at my test app (.exe) or myProj.dll, msvcr90.dll and msvcp90.dll are not found.

I'm guessing there's something I need to configure in VS2005 so that the .exe or myProj.dll are aware of the location of the 9.0 versions of the std C++ libraries (presumably where the redist package installed them in C:\WINDOWS\WinSxS), but I can't seem to figure out what it is. Am I on the right track?

I note that, if I simply copy the msvc*90.dll files to my app directory, then the dependency is resolved, but I get the run-time error about improper loading of std c++ DLLs, etc.

Thanks immensely in advance.

解决方案

This looks like a "Side-by-Side Assemblies" issue to me.

From what I can tell, Microsoft in an attempt to stop the DLL Hell problems of past years has introduced a concept of "Side-by-Side Assemblies".

In a nut shell it means that your application needs to tell Windows which version of the CRT it was designed to work with. When the application is installed Windows will make sure you application gets its own private copy of these DLL files.

To make it all work you need to embed the application's DLL dependencies into the applications Manifest file and attaching it to the project using the Manifest Tool, Input and Output section of the application project settings.

As an example here is the manifest I use for the Zeus for Windows IDE:

<?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>

Finally, if you plan to make an installer you will need to add the same versions of these DLL files to the application installer or alternatively have your installer run the Microsoft CRT redistributable installer.

FWIW I only found out about this when a user reported that Zeus no longer ran on Windows XP because of a missing MSVCRT runtime DLL file, yet Zeus had been working fine for over 10 years without ever once having to ship with a MSVCRT runtime DLL file.

这篇关于VS 2005 C ++项目中的msvcr90.dll依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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