问题
I'm using Visual Studio 2012. I wish to create a completely self-contained program that can be used on a machine without visual studio installed just by copying the exe file directly. I used to need to first run visual c++ 2012 redistributable to make the program work. Is there any way to make everything run in one exe? I would not like to use an installer either as it is a fairly simple program; the time it takes for the user to use the installer will probably be more than my program...
So is there any way to statically link everything? Right now, it just crashes when run on a new machine, but once I install VS2012 express on that machine, it suddenly starts to work.
Any help would be appreciated.
回答1:
To get static linking in an MFC project set the project properties (for the release build) as follows:
C/C++ Code Generation, Runtime Library: Multi-threaded (/MT)
Configuration Properties, General: Use of MFC: Use MFC is a Static Library
A simple exe with these properties will run standalone.
回答2:
Useful information found here http://msdn.microsoft.com/en-us/library/aa235516(v=vs.60).aspx
and here http://msdn.microsoft.com/en-us/library/f22wcbea.aspx
回答3:
Once you run your program, you can find it's executable in the Debug\ folder of your project.
Hope it helps! Sarge
来源:https://stackoverflow.com/questions/17386095/create-a-self-contained-program-in-c