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

Clinton Stimpson clinton at elemtech.com
Thu Aug 6 14:07:51 EDT 2009


Bill Hoffman wrote:
> 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 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 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.
>>
>
> No this works fine.... However you may be running into this issue:
>
> "
> Visual Studio 9 SP 1 has a bug that will cause trouble with cpack.
>
>
> You can read about it here:
>
> https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=361682 
>
>
>
> Basically, when you compile an executable or dll with VS9 SP1 it embeds
> manifest information into the the exe or dll that does not match the
> version information in the manifest files that SP 1 provides for
> redistribution.
> "
>
> We use the InstallRequiredSystemLibraries all the time without 
> requiring vcredist_x86.exe to be run.
>
There are some cases it doesn't work (3rd party libraries you can't 
compile yourself).
I don't have two installs of the same Visual Studio versions with 
different service packs, so, here's what I do.

    IF(MSVC80)
      FIND_PROGRAM(MSVC_REDIST NAMES 
vcredist_${CMAKE_MSVC_ARCH}/vcredist_${CMAKE_MSVC_ARCH}.exe
        PATHS
        
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0;InstallDir]/../../SDK/v2.0/BootStrapper/Packages/"
        
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\8.0;InstallDir]/../../SDK/v2.0/BootStrapper/Packages/"
        )
      GET_FILENAME_COMPONENT(vcredist_name "${MSVC_REDIST}" NAME)
      INSTALL(PROGRAMS ${MSVC_REDIST} COMPONENT Runtime DESTINATION bin)
      SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "ExecWait 
'\\\"$INSTDIR\\\\bin\\\\${vcredist_name}\\\"'")
    ENDIF(MSVC80)


Clint



More information about the CMake mailing list