How to make a Single Executable VS 2010
Asked Answered
C

2

2

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.

Cini answered 6/3, 2011 at 23:58 Comment(1)
You're better off with the installer method. You really don't want to statically link to the runtime and you want to make sure your project is distributable, as you would when you release it, anyway.Inspection
S
2

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:

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.
Seacock answered 7/3, 2011 at 0:5 Comment(1)
Thanks for the reply, this helped me get closer to what I was looking for, although I still can't get it working. I think it's because I don't have all of the static libraries like you said.Cini
G
3

If VS2010 is anything like VS2008, you need to go to project properties/c++/code generation and select a static runtime library.

Gatekeeper answered 7/3, 2011 at 0:3 Comment(0)
S
2

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:

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.
Seacock answered 7/3, 2011 at 0:5 Comment(1)
Thanks for the reply, this helped me get closer to what I was looking for, although I still can't get it working. I think it's because I don't have all of the static libraries like you said.Cini

© 2022 - 2024 — McMap. All rights reserved.