Stand Alone .exe in Visual C++

Hi I have a finished Win32 aplication in visual C++ 2008, I would like to create an .exe that I can transfer onto any computer. I have used the Release function and it produces an .exe but when I move it to another computer it says:

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

If anyone can help that would be great.
Statically link to the CRT; statically link to ATL and MFC if you use those too; finally do not embed a manifest file.

All these may carry consequences, though. This may or may not work for your particular case.
When I first started using VS nobody could seem to explain this to me simply. No offence, webJose, but I didn't know what static linking even meant, and I serously doubt that people who ask these questions do either.

Here's the simple answer for you --

Choose Properties | C/C++ | Code Generation | Runtime Library

Once there, for Debug versions choose "Multi-threaded Debug (/MTd)"

and for Release versions choose "Multi-threaded (/MT)"

Had someone told me that straight-up simple answer when I first asked it would have saved me (and many other people since then) a lot of time.

If for some strange reason that doesn't work, you must include the file "vcredist.exe" with your application, but I have NEVER had a problem with the above.
Last edited on
All these may carry consequences, though.

Possibly including licensing issues, although I'm not too sure of the details.
None taken, Lamblion. I just don't think I should be explaining that when it is found elsewhere. A Google search for "statically link to the crt" will give you an excellent document @ MSDN Online about the different options.

By not revealing specific details, users should search. By searching they should find what they look for and more, making them learn more than what their original question intended.

Besides: I am no administrative assistant for the OP. I'm not here to make executive summaries about how to configure a particular project, no offense to anyone, of course. I just think that if people are forced to search, they learn more AND doesn't take much more time from me. :-) A win-win situation, if you ask me.
Except the problem is when the question asked and the answer proffered seems to be a non-sequiter.

For example, the OP might not put it together that static linking and why his program won't work on another computer have any relation to each other.

I only had a hazy notion when I first asked and read a similar answer. That's how ignorant beginning programmers can be. They have to be walked through things.

Truth told, I can learn a LOT more from seeing the CODE of the "Hello World" program than I can from someone trying to explain to me how it's written.

Oh, don't get me wrong -- your points are certainly valid, but sometimes people who are experienced, such as yourself, don't understand how basic the knowledge is of beginners, and thus ofttimes you anwere them two or three levels over their head.

Of course, I can't speak for the OP, but only from personal experience and from reams of other people who ended up saying the same thing as me once they were finally pointed to the simple answer.

In short, I'm more of believer in DEMONSTRATION than EXPLANATION, although explanation certainly has its place.
I followed the steps and when I go to compile it it gives me this error:

Command line error D8016 : '/MT' and '/clr:pure' command-line options are incompatible cl

I hope some one can help me.
You cannot statically link to the CRT if you are also using .Net. This means your program is not really C++, but C++/CLI, effectively a different animal.

You cannot produce an executable in C++/CLI that can run standalone. You'll have to produce an installer or move to unmanaged C++.
Is there a way to produce an installer in visual C++ 2008, if not how can I move it to an unmanaged C++?
You could write setp programs, does not matter if you use managed or unmanaged code, but this feature is not available in Express Edition.

My advice is to use NSIS ( http://nsis.sourceforge.net/ ) for free and much. much better than Microsoft product (I use VS 2010 Ultimate which costs a lot of money).
Moving to unmanaged C++ will involve learning the standard C++ library, among other things. CLI/C++ is based on C++, but they are different langauges.

Look up Visual Studio Click Once install, which might provide you with a way of creating an installer using Visual Studio.

Failing that, perhaps this thread would be helpful.
http://cplusplus.com/forum/windows/44445/
In this case you would also have to look into getting hold of a redistributable for .NET.
I would switch to another program but I am currently using file read functions that I don't know in straight C++. The other thing is that i'm a student and this project is due soon and I don't have time to rebuild parts of my program.

If any one has a quick fix that would be great or I will have to hand in my computer as evidence.....
I have also looked at that forum (http://cplusplus.com/forum/windows/44445/) and I have an installer but the problem is my program doesn't work on other computers.
Your users needs to have Visual Studio Redistributable and .NET Framework installed to run your program. You could bundle both with your installer or just send the users to Microsoft download page.
Look for the file "vcredist.exe" and the .NET framework and include this wilt your executable to go on the other computers. I am not familiar with CLR methodology so someone else will have to guide you through the actual steps.

If anyone can help, simply provide him with --

1. do this...
2. do this..

etc. At least for now -:)
Topic archived. No new replies allowed.