Problems with running EXE file built with Visual Studio on another computer
Solution 1
I deployed my program in release instead of debug, and the EXE file now works on the other computer.
Solution 2
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:
Basically you have two options: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.
- 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 :)
Solution 3
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).
- Statically link run-time assemblies with your application (troublesome for large application).
- Install the C++ redistribution environment on the target computer (the easiest way).
- Creating a setup project to deploy the run-time on the target computer when installing the application (not bad).
- 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
Solution 4
I haven't seen that specific error before. Usually it's an error around a missing DLL (Windows redistributable). Assuming there isn't actually a problem with the configuration, you have two choices:
Change the compile mode from Multithreaded DLL to Multithreaded. This can be done from the C++ section of project properties under code generation. In multithreaded mode your binary will be statically linked against the Windows redistributable. This is probably what you want.
Install the Windows redistributable on the target machine. This probably isn't OK, because you state that you don't want to install anything on the target machine.
A warning about option 1: Different versions of Windows have different versions of the redistributable. It's possible to encounter a highly specialized environment in which a statically linked program will not behave as expected.
Solution 5
It look like you're missing some DLL files. Be sure to copy appropriate DLL files along with EXE file.
Related videos on Youtube
Karen123456
Updated on January 03, 2022Comments
-
Karen123456 over 2 years
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?
-
j.karlsson about 11 yearsDoes the computer have the correct version of the C runtime library. It is very common the inlcude msvcrtXX.dll where XX is the version no. in an installation package.
-
-
Caesar about 11 yearsIt sounds like he is missing the VC++ runtime DLLs. He asking how he can send an exe without them and so your answer doesn't help.
-
Nate Hekman about 11 years+1 for suggesting static linkage. That's the real answer to the OP's question (how to run without installing anything).
depends
is a great tool to figure out what libraries are missing. -
Sheng Jiang 蒋晟 about 11 yearsThe answer does help if the missing dependency is not the C++ redistributable. You do realize programmers can use all kinds of dlls, not just MSVC ones, right?
-
JBentley about 11 years@caesar no, he did not say send an .exe without them, he said without installing anything, so this answer is fine.
-
JBentley about 11 yearsIn my opinion this should be the accepted answer, because it is the only one to mention the private assemblies option. Some of the other answers are plain wrong, because they state that there are only two options (and one of those options is useless to the OP because she has a constraint of not installing anything on the target machine).
-
JBentley about 11 yearsThere are more than two options. See Nayana's answer.
-
JBentley about 11 yearsYour second bullet point doesn't help the OP because she has as a constraint that she can't install anything on the target machine. There are also more than two solutions - see Nayana's answer.
-
Karen123456 about 11 yearsi have tried Deploying run-time assemblies and installing C++ redistribution but i still get the same error
-
Karen123456 about 11 yearssorry but i can't change from DLL. and also I am trying to run the exe file without installing something on the other computer
-
Nayana Adassuriya about 11 yearsOk, I'm gonna help you now, so you have to reply me fast :), your application includes only one
exe
or is it includes with any otherDLLs
? -
Russell over 7 yearsHad this exact same problem. Any .dll that your app requires is placed in the Release folder. So when I copied out just the .exe it wouldn't open because it was looking for the .dll. Bring along your .dlls with the .exe or remove the dependency if you can.