如何分配C运行时(CRT)库 [英] How to distribute C run-time (CRT) Libraries

查看:174
本文介绍了如何分配C运行时(CRT)库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual C ++ 2008 express上转换VC ++ 6工作区后,我正在构建一个应用程序。构建本身就成功了,但真正的问题在于生成的清单如下所示:

 <?xml version = '1.0'encoding ='UTF-8'standalone ='yes'?> 
< assembly xmlns ='urn:schemas-microsoft-com:asm.v1'manifestVersion ='1.0'>
< trustInfo xmlns =urn:schemas-microsoft-com:asm.v3>
< security>
< requestedPrivileges>
< requestedExecutionLevel level ='asInvoker'uiAccess ='false'/>
< / requestedPrivileges>
< / security>
< / trustInfo>
<依赖关系>
< dependentAssembly>
< assemblyIdentity type ='win32'name ='Microsoft.VC90.CRT'version ='9.0.30729.1'processorArchitecture ='x86'publicKeyToken ='1fc8b3b9a1e18e3b'/>
< / dependentAssembly>
< / dependency>
<依赖关系>
< dependentAssembly>
< assemblyIdentity type ='win32'name ='Microsoft.VC90.CRT'version ='9.0.21022.8'processorArchitecture ='x86'publicKeyToken ='1fc8b3b9a1e18e3b'/>
< / dependentAssembly>
< / dependency>
< / assembly>

我的问题是:



我限制清单只列出一个版本,最好是9.0.21022.8。所以我可以在我的应用程序中捆绑必要的C-Run时间依赖关系?



我知道这个问题的根本原因是依赖于使用9.0.21022.8我的VC ++ Express 2008可能使用9.0.30729.1。这就是为什么两者被列为依赖关系。



注意:



我正在遵循方法b) http:/ /www.codeproject.com/Tips/211756/How-to-Distribute-C-run-time-CRT-Libraries-with-Yo?display=Print 涉及复制CRT DLL文件和Microsoft.VCXX .CRT.manifest文件在应用程序文件夹内。

解决方案

Visual Studio 2008的默认值是绑定到版本9.0.21022.8。这是无论您安装的任何版本的Service Pack或修补程序,因为Visual Studio的更新不一定强制您的应用程序必须升级(如 here )。



其他可能的版本是Service Pack 1的9.0.30729.1或具有安全更新的SP1的 9.0.30729.6161 。还有其他的。



由于默认行为,您的应用程序很可能正在使用9.0.21022.8,并且有一个库被编译为使用9.0.30729.1 。您可以使用以下命令行找出每个库所依赖的版本(这里描述):

  dumpbin / directives < name> .lib 

为了控制应用程序绑定的运行时版本可以在项目设置中定义预处理器符号(必须在项目设置中)或命令行)绑定到默认版本(9.0.21022.8 - 通过不定义它们)或绑定到与您安装的Visual Studio 相同的版本

  _BIND_TO_CURRENT_VCLIBS_VERSION = 1 

显然你也可以使用这个答案应该已经发现,先输入所有这些:)。



如果你发现是你的应用程序绑定到9.0.30729.1,并且依赖库绑定到9.0。 21022.8然后你只需要删除预处理器定义。



另一个困难是当您升级Visual Studio时,可重新分发文件夹中的运行时合并模块也升级到版本。因此,如果您有一个使用这些合并模块的安装项目,并且您尝试绑定到默认版本,则最终将安装新版本的运行时。



解决方案如果您还分发运行时策略合并模块,则运行时版本不会出现问题,因为库加载程序将在运行时查看运行时的策略,并自动加载最新版本,即使您绑定到默认版本。即使使用私人程序集,加载程序将首先看看WinSxS文件夹,所以如果政策在那里你将绑定到最新的版本。因此,您的清单中的混合版本号将重定向到最新版本。



有时这是不需要的,您可以控制它强制它仅加载版本您指定的清单,在


I'm building an application after converting VC++ 6 workspace on Visual C++ 2008 express. Build in itself goes successfully but real problem I have is with the generated manifests which looks like this:

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level='asInvoker' uiAccess='false' />
      </requestedPrivileges>
    </security>
  </trustInfo>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type='win32' name='Microsoft.VC90.CRT' version='9.0.30729.1' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
    </dependentAssembly>
  </dependency>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type='win32' name='Microsoft.VC90.CRT' version='9.0.21022.8' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
    </dependentAssembly>
  </dependency>
</assembly>

My Question is :

How can I restrict the manifest to list only ONE version , preferably 9.0.21022.8. so that I can bundle the necessary C-Run time dependencies inside my application ?

I know the possible root cause to this problem is dependency on some library which uses 9.0.21022.8 and my VC++ Express 2008 might be using 9.0.30729.1. that's why both are listed as dependency.

Note:

I'm following approach b) of http://www.codeproject.com/Tips/211756/How-to-Distribute-C-run-time-CRT-Libraries-with-Yo?display=Print which talks about copying the CRT DLL files and Microsoft.VCXX.CRT.manifest file inside application folder.

解决方案

The default for Visual Studio 2008 is to bind to version 9.0.21022.8. This is regardless of whatever version of service pack or hotfix you have installed, since updates to Visual Studio should not necessarily force your application to have to upgrade (as described here).

Other possible versions are 9.0.30729.1 for Service Pack 1 or 9.0.30729.6161 for SP1 with a security update. There are others.

Because of the default behaviour, it is likely that your application is using 9.0.21022.8 and there is a library which has been compiled to use 9.0.30729.1. You can find out what version of each library is dependant on by using the following command line (described here):

dumpbin /directives <name>.lib

In order to control the version of the runtime that your application binds to you can define preprocessor symbols in your project settings (must be in the project settings or on the command line) to either bind to the default version (9.0.21022.8 - by not defining them) or binding to the same version as your installed Visual Studio:

_BIND_TO_CURRENT_VCLIBS_VERSION=1

Apparently you can also specify the exact version you want to bind to using the defines from this answer (maybe I should have found that first before typing all this out :).

If you find it is your application that binds to 9.0.30729.1 and the dependant library is binding to 9.0.21022.8 then you simply need to remove the preprocessor definition.

The other difficulty is that when you upgrade Visual Studio, the runtime merge modules in your redistributable folder are also upgraded to those versions. So if you have a setup project that uses those merge modules and you are trying to bind to the default version you would end up installing the new versions of the runtimes.

Resolving the runtime version would not be a problem if you also distribute the runtime policy merge modules, as the library loader will at runtime look at the policy of your runtime and automatically load the newest version even if you bind to the default version. Even with private assemblies the loader will first look in the WinSxS folder so if the policies are there you will bind to the newest version. So your mixed version numbers in your manifest will both redirect to the newest version.

Sometimes that is not desired and you can control that to force it to load only the version in the manifest that you specify, which is explained in an answer to this similar SO question.

这篇关于如何分配C运行时(CRT)库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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