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?
TSF is not compatible how? what do you get? linker errors? compile errors? most of those errors can be handle by a various compile/link flags.
The easiest way will be to build your DLL with a VC++ version that uses the CRT that is compatible with TFS.
I don't think that it is a good idea just to link your DLL with a different version of the CRT, unless you also use the same version of the header files. And the easiest way to do that will be to use the right VC++ version...
If you still want to try, you can:
- go to "Configuration settings->Linker->Input->Ignore specific library" and enter the crt you are using (libc.lib, libcmt.lib, etc. see this code project article for details).
- Enter the name of the crt version you want to use in "Configuration settings->Linker->Input->Additional dependencies", and its path in "Configuration settings->Linker->General->Additional library directories".
You can also try to change the default directories in "Tools->Options->Projects and solution->VC++ directories->library files". Maybe changing $(VCInstallDir)lib to the path where you other version of the CRT resides will do the trick
Don't try to use VS9 and link to another version of the CRT.
If you need your app to link to another CRT, say VS8's CRT, then you must compile & link your app in that version of VS.
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.