Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with running EXE file built with Visual Studio on another computer

Tags:

I created a client server application in C++ using Visual Studio.

Now I want to run the client EXE file on another computer (which doesn't have Visual Studio installed), but when I try run the EXE file, it gives the following error message:

This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.

How can I run the EXE file without installing anything on the computer?

like image 564
Karen123456 Avatar asked Mar 08 '13 15:03

Karen123456


People also ask

How do I run exe files on another computer?

You may Share a folder containing the .exe on your computer within the domain and use telnet to get a command line on the other computer to run the program.

How do I run an EXE file in Visual Studio?

In Visual Studio, select File > Open > Project. In the Open Project dialog box, select All Project Files, if not already selected, in the dropdown next to File name. Navigate to the .exe file, select it, and select Open. The file appears in a new, temporary Visual Studio solution.

Where is Visual Studio exe stored?

The \Microsoft\VisualStudio\Shared directory is where Visual Studio stores the files that are shared by side-by-side Visual Studio installations. SDKs and tools are also stored in this directory.


2 Answers

Applications built with Visual Studio depend on Visual C++ Redistibutable (VCRedist). When the program is being linked dynamically, then your binaries will need MSVCR**.dll (Microsoft C Runtime Library).

On MSDN, there is a nice article called Redistributing Visual C++ Files (for Visual Studio 2008), that states that there are Potential run-time errors in case that required Visual C++ library is not installed:

you may get one of the following error messages depending on the version of Windows on which you try to run your application:

  • The application failed to initialize properly (0xc0000135).
  • This application has failed to start because the application configuration is incorrect. Reinstalling application may fix this problem.
  • The system cannot execute the specified program.
Basically you have two options:
  • The simplest possible solution is to change the dynamic linking of runtime libraries to static linking. Go to project properties and under C/C++ → Code Generation you will find Runtime Library option. You need to change it from Multi-threaded DLL (/MD) to Multi-threaded (/MT).
  • Another possible solution is to make sure that the right version of Microsoft VC++ Redistributable Package is installed on the target machine.

But your application might depend on other DLL files as well. In case you want to find out what are the dependencies of your program, there is a great utility called Dependency Walker that will help you in this and many other situations :)

like image 70
LihO Avatar answered Dec 15 '22 07:12

LihO


Background:

  • C++ applications need run-time assemblies (DLL files) to run in any Windows computer.
  • Normally these run-time assemblies are located at C:\Windows\Winsxs directory.
  • All the Windows operating systems by default comes with several run time assemblies.
  • But if your application is developed in a newer version of the run-time assembly environment, the target computer also needs the same version of the run time to exist there.
  • When you're installing Visual Studio, most newer versions of the run-time assemblies comes to your computer.

Solution:

Finally by anyway the target computer should have the exact run time assemblies. There are a few ways to do this (for more details search each in Google).

  1. Statically link run-time assemblies with your application (troublesome for large application).
  2. Install the C++ redistribution environment on the target computer (the easiest way).
  3. Creating a setup project to deploy the run-time on the target computer when installing the application (not bad).
  4. For deploying run-time assemblies as private assemblies (professional), see here for more details

Conditions:

  • You must not use .NET framework in your application.
  • You must not use the common language run-time support for your application
like image 36
Nayana Adassuriya Avatar answered Dec 15 '22 09:12

Nayana Adassuriya