Click here to Skip to main content
15,881,967 members
Articles / Programming Languages / C++
Tip/Trick

How to Distribute C run-time (CRT) Libraries with Your Application

Rate me:
Please Sign up or sign in to vote.
5.00/5 (4 votes)
16 Jun 2011CPOL2 min read 178.9K   10   4
Some tips on available ways of distributing CRT DLLs with your Visual C++ application
My application doesn't start because of error message 'The application configuration is incorrect'. What do I do?

This error typically means your application can't load the correct C run-time libraries (CRT). This tip describes how to address this problem.

First of all, determine what DLL modules your application depends on. You can do this with the help of the Dependency Walker (depends.exe)[^] tool. Open your executable file with the depends.exe to see what CRT modules it depends on. Typically, these modules are msvcrXX.dll and msvcpXX.dll, where XX is the version number of your Visual Studio (for example, Visual Studio 2005 has version number 80).

Next, you need to determine the exact version of CRT libraries you use. Microsoft usually upgrades CRT version when releasing service packs and hot fixes for Visual Studio, so this step is very important. To determine the version of your CRT, do the following. In your Visual Studio window, click menu File->Open and open your executable module to view its embedded resources. In appeared window, click RT_MANIFEST folder to see the embedded manifest XML file. The version of CRT is defined by the version attribute. An example CRT manifest is presented below:

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.VC80.CRT" version="8.0.50608.0"
processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
    </dependentAssembly>
  </dependency>
</assembly>


Next you should choose how to distribute the CRT files. There are two ways: either by installing a Visual C++ redistributable package or by installing the DLLs to application local folder (an application local folder is a folder that contains an executable application file). Below these two alternatives are described.

  1. You can download a Visual C++ Redistributable package from the Microsoft Download Center[^]. There are different packages for x86 and x64 architectures, choose the correct one. Also ensure the package has exactly the same version that your CRT manifest has. If version doesn't match, search again for the correct redistributable package. When the correct package is downloaded, you can include it into your application installer and install it with your software.

  2. You can copy CRT DLL files and Microsoft.VCXX.CRT.manifest file to your application folder, where XX is the version number. This is called a private installation, because these CRT DLLs won't be shared with other applications. This way may also reduce the size of your installer, because CRT DLLs usually take less space than a redistributable package. You can take the correct CRT DLL files from vcredist subfolder of your Visual Studio folder or from the Visual C++ redistributable package (it is installed to C:\WINDOWS\WinSxS directory).

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Russian Federation Russian Federation
I am a software developer currently living in Tomsk, Russia. I received a PhD degree in Computer Science from Tomsk Polytechnic University in 2010. I have been professionally developing C/C++ and PHP software since 2005. I like contributing to open-source and writing programming articles for popular web resources, like CodeProject. Besides writing, I love skiing and watching Formula-1.

Comments and Discussions

 
Questiononly two DLLs are required in Visual Studio 2017? Pin
Southmountain29-Aug-20 10:17
Southmountain29-Aug-20 10:17 
GeneralWhat is the best solution when I have two modules in the sam... Pin
Mojoturner28-Jul-11 7:12
Mojoturner28-Jul-11 7:12 
GeneralDoes Microsoft's License Policy allow to redistribute select... Pin
Aoi Karasu 15-Jun-11 22:34
professional Aoi Karasu 15-Jun-11 22:34 
GeneralRe: Yes, Microsoft provides both ways: using vc_redist.exe or us... Pin
OlegKrivtsov16-Jun-11 1:15
OlegKrivtsov16-Jun-11 1:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.