views:

280

answers:

3

I know there are a few similar questions, but I don't think they really have the same requirements as mine.

Our DLL is compiled with Visual Studio 2005 and must link with a specific version of the CRT, due to installation constraints. This is absolute, recompiling it with the latest version is not a solution.

We recently updated our Boost libraries. However, when I built Boost, it automatically used the latest CRT. Now, when I link Boost with our program, it creates a dependency on both the newest (wrong) version of the CRT and the old (correct) version of the CRT. The dependency on the newest version needs to go.

What is the best solution to this problem? At the moment, the best I can think of is rebuilding Boost using the old version, but I have no idea how to easily do that without modifying the source.

If there were a way to force Visual Studio to use a specific version of the CRT globally (not on a per-project basis), that would be great. Or a way to just plain remove the newest version of the CRT, but I'm pretty sure that's not possible since I think it's considered part of the OS.

+4  A: 

AFAIK, It is not recommended to use different versions of CRT. Unlike .NET where you can refer to a .NET 1.1 dll from a .NET 2.0 dll, Unmanaged does not provide that flexibility.

Since you cannot upgrade your dlls to use newer CRT, the only thing you can do is rebuild Boost in VS2005.

Also it is not recommended to linking two dlls of different CRT. It can lead to issues like memory corruption.

Note: Each Visual Studio has its default CRT version to which all dlls refer.

Also I did not understand "remove the new CRT". You will need to install the Visual Studio Redist for each version of Visual Studio you use. (That redist contains the CRT dll) http://msdn.microsoft.com/en-us/library/abx4dbyh%28VS.80%29.aspx

Ganesh R.
The line starting "No each" doesn't read quite right, should "No" be "Note"?
Andrew O'Reilly
We are only building with Visual Studio 2005. The difference is one version of the CRT is from the latest service pack and the other (correct) version is from an older service pack. We'd prefer is Visual Studio _always_ used the old version.
dauphic
Visual Studio 2005 has two versions till date. 1. 'RTM' 2. 'SP1'. Each CRT will differ in minor version. However If you build both your project as well as Boost on the same machine (same Visual Studio), both will link to the same CRT. Hence you will not face any issues of linking to different CRT version. Always prefer to build against Visual Studio with latest SP, because the SP is released with a reason.
Ganesh R.
+2  A: 

The solution was manually modifying the embedded manifest to remove the dependency on the newest CRT, since it's built with the CRT dynamically linked. I question the safety of this, though.

For some reason, force including a targetsxs file during the Boost build process didn't force it to target the specified CRT.

dauphic
A: 

You have to find exactly which construct in the boost project injects the dependency on the wrong CRT and remove/modify that construct. It might be something in .vcproj file or some manifest or something like that.

VC++ 2005 and VC++ 2008 CRTs contain more or less the same primitives - you likely can recompile boost entirely with VC++ 2005 or tweak it a bit and recompile after that. Yes, this will require some effort, but it is the only way to go - both your code and boost code must be compiled against the version of CRT you want to use.

sharptooth