如何强制C ++编译器使用特定的CRT版本? [英] How to Enforce C++ compiler to use specific CRT version?

查看:261
本文介绍了如何强制C ++编译器使用特定的CRT版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用VS2008开发一个COM DLL,默认情况下使用CRT版本9
,但我使用TSF(文本服务框架),与新的CRT不兼容。我认为解决方案是使用兼容的,那么如何指定CRT版本?

I am using VS2008 for developing a COM dll which by default uses CRT version 9 but I am using TSF (Text service framework) that is not compatible with the new CRT. I think the solution is to use the compatible one so how can I specify the CRT version?

推荐答案

手动更改您链接的CRT版本。然而,如果由于某种原因(我不能想象),这是你的正确行动方案,这样做的方式是更改 Manifest

I whole heartily join the recommendation not to manually change the CRT version you link against. If however, for some reason (which I cannot imagine) this is the right course of action for you, the way to do so is change the manifest for your project.

首先确保每个版本都生成了一个清单 VS2005:配置属性/链接器/清单文件/生成清单),因为它将覆盖您的手动更改。还要确保启用隔离。
接下来,找到清单文件 - 应该在$(IntDir)(例如,Debug)。您应该会看到类似于

First make sure a manifest is not generated on every build (on VS2005: Configuration properties/Linker/Manifest file/Generate manifest), as it would overwrite your manual changes. Also make sure there that isolation is enabled. Next, locate the manifest file - should be at the $(IntDir) (e.g., Debug). You should see a section similar to -

  <dependency>
    <dependentAssembly>
      <assemblyIdentity type='win32' name='Microsoft.VC80.DebugCRT' version='8.0.50727.762' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
    </dependentAssembly>
  </dependency>

(对于调试生成,当然)。您需要编辑CRT元素的版本和publicKeyToken属性。
您可以检查本地WINDOWS \WinSxS文件夹中的文件,以查看可用的版本。检查此处如何在找到所需版本后解压缩publicKeyToken 。 (虽然我会先尝试直接查看其他项目的清单,链接到你想要的CRT版本)。

(For debug builds, of course). You need to edit the version and publicKeyToken attributes of the CRT element. You can inspect the files at your local WINDOWS\WinSxS folder to see the versions available. Check here how to extract the publicKeyToken once you find the version you want. (Although I'd first try and look directly into manifests of other projects, linking against your desired CRT version).

如果你去那里,如果您的应用程序是不与其他并行组件(MFC,OpenMP等)链接的控制台应用程序,您可能会有一些运气。如果你的应用程序是不平凡的,我会惊讶,如果没有一些复杂的版本依赖的SxS组件。

If you do go there, expect some rough water. You may have some luck if your application is a console app that does not link against other Side-by-Side components (MFC, OpenMP, etc.). If your application is non-trivial, I'd be surprised if there aren't some intricate version dependencies amont the SxS components.

(编辑)你还需要与您的应用程序分发您正在使用的特定CRT。这是执行此操作的某人

(edit) You'd also need to distribute with your application the specific CRT you're using. Here's someone who did that.

这篇关于如何强制C ++编译器使用特定的CRT版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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