C++ – Distributing the Visual C++ Runtime Libraries (MSVCRT)

cvisual c++

I have an ATL/WTL project developed using Visual Studio 2008 and up until now I have been statically linking with the CRT libraries, avoiding the need to ship them. However, I now need to consider using the dynamic libraries (DLL) instead – in order to reduce the size of the code and because I want to use the excellent crashrpt tool (which requires you dynamically link to the CRT.)

Now, MS supply both a stand-alone installer (vcredist_x86.exe) and an MSM package but this is no good for me for two reasons:

  • I am not using an MSI based installer (I am using InnoSetup).
  • My application installs on a limited user account and the vcredist_x86.exe installer will not work.

Therefore I want to ship the CRT DLLs and install then in my applications program folder. Now, this is something you can do as I found the following blog post by Martyn Lovell, the MSVC Libraries Development Lead that says:

However, if you want to
install-applocal, you should make sure
that your application has a manifest,
and then copy the whole of this folder
into your EXE directory:

X:\Program Files\Microsoft Visual
Studio
8\VC\redist\x86\Microsoft.VC80.CRT

and other folders if you use more than
the CRT. Make sure you include the
manifest.

Just want I am after – except I don't understand this part:

make sure that your application has a manifest

My question is – how do I create an application manifest that references the CRT DLLs I want to use? The only manifest information my projects currently use is the following (which ensures the app uses v6 of the Common Controls):

/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"

Can someone provide me with instructions on how to work the manifest magic using Visual Studio 2008? There is a Microsoft.VC90.CRT.manifest file in my Visual Studio VC\redist\x86\Microsoft.VC90.CRT folder – do I need to use this somehow?

Note: This is a similar – but different – question to this one.

Best Answer

Visual Studio will generate the correct manifest for you when you pass the /MD flag.