[CMake] InstallRequiredSystemLibraries.cmake and Redistribution of the shared C runtime component in Visual C++

Marcus D. Hanwell marcus at cryos.org
Thu Aug 6 13:58:06 EDT 2009


James Bigler wrote:
> I've just been bitten hard by this issue (many hours of frustration
> while attempting to run a demo application that should have "Just
> Worked" (TM) ).
>
> According to this page:
>
> http://support.microsoft.com/kb/326922
>
>
> "You should install these versions of the CRT on target computers by
> running the Vcredist_x86.exe application that is included with Visual
> Studio."  This is for the VS 2005 and 2008 versions of the C run-time
> libraries except for Windows 2000 in which case you need to install
> them in the system32 directory.

I hit this with Avogadro development, and at the time from my searching
it appeared that this is due to the version numbers being incorrect in
the manifest that MS distributes with the DLLs in question. By editing
the manifest for the DLLs they would load as expected on XP and Vista
hosts. This seems to work, and so I edited the manifest in the
redistributable folder and we have been using that ever since.

>
> I was dropping Msvcr80.dll and friends as per
> InstallRequiredSystemLibraries next to the binaries with ineffectual
> results.  It was really strange, because programs like Dependency
> Walker seemed to find them just fine.  It was only after running
> vcredist_x86.exe that I was able to run my programs properly.

I am sure there are people on this list who know better than I, but I
think this is because the version number in the manifest MS supplies
with the redistributable DLLs is incorrect. Changing this version fixed
it for me, but did feel a little hackish. I would be interested in what
the best practice is. Currently we can run our application from a flash
drive without installing on a "clean" system, which is a feature I would
also like to retain.

>
> I though I should tell everyone that this method of distributing
> Msvcr80.dll and Msvcr90.dll next to your binaries is not supposed to
> work.  You must install them into the Windows Side by Side location
> (WinSxS) using the CRT.msm merge module or the vcredist_x86.exe that
> comes with Visual Studio.
>
> Now to try and get CPack to tell NSIS run the vcredist_x86.exe program
> during installation.
>
> Note, that many people might get lucky and have already installed a
> product that installed the right vcredist_x86.exe before installing
> your software.
>
I would be interested in how others have solved this issue. I like our
current solution and I think several Kitware projects use a similar
mechanism.

Marcus


More information about the CMake mailing list