Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
388 views
in Technique[技术] by (71.8m points)

c++ - Problems with running EXE file built with Visual Studio on another computer

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 :)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...