2

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.

l3utterfly
  • 2,106
  • 4
  • 32
  • 58
  • By the way, it uses MFC, I'm not sure if that makes it simpler or more difficult... – l3utterfly Jun 30 '13 at 01:00
  • You can statically link with \MT rather than the default \MD option but I don't know if this is enough to avoid the redistributable – a.lasram Jun 30 '13 at 01:13

3 Answers3

4

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.

ScottMcP-MVP
  • 10,337
  • 2
  • 15
  • 15
-2

Once you run your program, you can find it's executable in the Debug\ folder of your project.

Hope it helps! Sarge

Sarge
  • 1
  • 2
  • 3
    And it will require a few dozen DLLs to run, which can only be (legally) installed using the distributable packages which can be multi-megabyte downloads. This is not the answer – sehe Jun 30 '13 at 01:05