Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Enforce C++ compiler to use specific CRT version?

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?

like image 359
Ahmed Avatar asked Apr 08 '09 13:04

Ahmed


1 Answers

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.

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>

(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).

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.

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

like image 116
Ofek Shilon Avatar answered Nov 10 '22 21:11

Ofek Shilon