views:

670

answers:

6

After compiling a simple C++ project using Visual Studio 2008 on vista, everything runs fine on the original vista machine and other vista computers. However, moving it over to an XP box results in an error message: "The application failed to start because the application configuration is incorrect".

What do I have to do so my compiled EXE works on XP and Vista? I had this same problem a few months ago, and just fiddling with some settings on the project fixed it, but I don't remember which ones I changed.

+1  A: 

You need to install the runtime redistributable files onto the machine you are trying to run the app on.

The redistributable for 2008 is here.

The redistributable for 2005 is here.

They can be installed side-by-side, in case you need both.

1800 INFORMATION
Yes, but I'd rather not have to make users do that. Is there no way to compile against older libraries?
+6  A: 

You need to install the Visual Studios 2008 runtime on the target computer:

http://www.microsoft.com/downloads/details.aspx?FamilyID=9b2da534-3e03-4391-8a4d-074b9f2bc1bf&displaylang=en

Alternatively, you could also link the run time statically, in the project properties window go to:

c++ -> Code Generation -> Runtime Library and select "multi-threaded /MT"

rhinovirus
Thanks that option is what I was looking for.
A: 

If you don't have SP1 installed, copy the $PROGRAMFILES$\Microsoft Visual Studio 9.0\vc\redist\x86\Microsoft.VC90.CRT contents and/or $PROGRAMFILES$\Microsoft Visual Studio 9.0\vc\redist\x86\Microsoft.VC90.MFC, making sure to include the manifest files.

Take a look at this for an example: Deploying Visual C++ library DLLs as private assemblies

If you have SP1 installed, you need to define _BIND_TO_CURRENT_VCLIBS_VERSION=1 since the redist folder has SP1 versions and VS still links to the RTM versions by default. This means that any DLL you use must also link to the SP1 versions as well.

Or, install the vsredist_x86.exe

crashmstr
+1  A: 

You probably need to distribute the VC runtime with your application. There are a variety of ways to do this. This article from the Microsoft Visual C++ Team best explains the different ways to distribute these dependencies if you are using Visual Studio 2005 or 2008.

As stated in the article, though you can download the Redistributable installer package and simply launch that on the client machine, that is almost always not the optimal option. There are usually better ways to include the required DLLs such as including the merge module if you are distributing via Windows Setup or App-Local copy if you just want to distribute a zipped folder.

Another option is to statically link against the runtime libraries, instead of distributing them with your application. This option is only suitable for standalone EXEs that do not load other DLLs. You also cannot do this with DLLs that are loaded by other applications.

Dusty Campbell
A: 

It is much the simplest to link to the runtime statically.

c++ -> Code Generation -> Runtime Library and select "multi-threaded /MT"

However, this does make your executable a couple hundred KByte larger. This might be a problem if you are installing a large number of small programs, since each will be burdened by its very own copy of the runtime. The answer is to create an installer.

New project -> "setup and deployment" -> "setup project"

Load the output from your application projects ( defined using the DLL version of the runtime ) into the installer project and build it. The dependency on the runtime DLL will be noticed, included in the installer package, and neatly and unobtrusively installed in the correct place on the target machine.

ravenspoint
A: 

Visual studio 2005 actually has two

The one for the original release

and the one for SP1

shoosh