msvcr90.dll依赖在VS 2005 C ++项目 [英] msvcr90.dll dependency in VS 2005 C++ project

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

问题描述

我在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),它依赖于thirdParty.dll。



我安装了Microsoft的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 ++ DLLs等的运行时错误。



非常感谢提前。

解决方案

这看起来像一个并列的装配发给我。



我可以告诉,微软在试图阻止过去几年的 DLL Hell 问题已经引入了并排组件的概念。



在坚果外壳中,这意味着您的应用程序需要告诉 Windows 哪个版本的 CRT 是为了使用它。当应用程序被安装Windows将确保你的应用程序获得自己的私人副本的这些DLL文件。



为了使所有工作,你需要嵌入应用程序的DLL依赖关系应用程序项目设置的清单工具输入和输出部分将应用程序清单文件附加到项目。



下面的示例是我用于 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>

< 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 不再在Windows XP上运行,因为缺少MSVCRT运行时DLL文件,但 Zeus 已经工作了10多年,没有一次运行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.

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

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