Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

The solution worked for me with Visual Studio Express 2013 x64 + OpenCV 2.4.9 x64 compiled, debug (I integrated that in LV2013 x64), but it should work for any other VS-version:

1) Right-click on your Solution > Properties > Debug Source Files ...

2) There are maybe two entires (depending on your VS-install-directory)... C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\vc7\atlmfc C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\vc7\crt

With these it would work for Visual Studio 2013 Express but should also work for other 2013. If you've got Visual Studio 10 or 11 just type "Microsoft Visual Studio 11.0" or 10.0 in each. You can also just add them.

These entries you can get from your OpenCV.sln under Solution > Properties > Debug Source Files (as described above). And as already decribed: CRT needs to match... and this happens in that place.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top