I'm making a game using C++ and DirectX and it'd be nice to share my groups progress with other people by providing a single executable file instead of having to run a setup wizard.
I've checked my Release and Debug folders but those executable don't work. The release .exe is something like 21KB which doesn't开发者_如何学编程 seem right.
So I guess what I'm asking is how to make a single executable with all of the libraries and resource files included.
If VS2010 is anything like VS2008, you need to go to project properties/c++/code generation and select a static runtime library.
You need to specify that all your libraries have to be statically linked in. There are several threads about doing this in Visual Studio, like:
- How do you pack a visual studio c++ project for release?
- How do I make a fully statically linked .exe with Visual Studio Express 2005?.
However, to add on to those answers linked, be aware that:
- You must have actual static libraries to link against. In many instances,
.lib
files in Windows land are stub libraries that link to the DLL. - Perhaps not everything you need to be statically linked can be (i.e. you will not find a static link library of it)
- You don't have to distribute your binary as a completely statically linked executable. You can ship all the dependent libraries in the same directory as your executable. This could simplify future sharing as you'd only have to replace some libraries vs. sending the entire file to everyone.
精彩评论