Creating a stand alone .exe

Dec 9, 2011 at 4:06pm
Hey this might be too simple a question and should be in beginners so apologies if so. If not here we go:

I am using Visual Studio 2008 Express Edition.
I've made a project to simulate betting and I want to give a copy to my mate. If I give him a copy of the executable from the debug folder then he won't have the necessary files/libraries to run it. I've looked up some stuff to try and understand how I can make the executable independent of other files. It seems I need to change one of the properties of the project. Specifically I need to change the runtime library to multithreaded (/MT). I changed this and when I rebuilt my project I ended up with hundreds of errors. So clearly there's something else I need to do before I can build it and send the executable to my mate.

In case it matters I am using precompiled headers and the stuff at the top of the code is:

1
2
3
4
5
6
#include "stdafx.h"
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <time.h>
using namespace std;


I should mention I'm really not that experienced in C++ or even programming. Please speak slowly and use small words!

Thanks very much in advance.
Dec 9, 2011 at 4:54pm
You must never distribute DEBUG versions. Don't. You must compile a Release version of your application and distribute that. You also change to /MT in the Release version only. If you must, you may change DEBUG to /MTD so as to avoid the hundreds of errors you are getting.

DEBUG and RELEASE are configurations for your project. Get familiar with the concept before changing too much the settings.
Last edited on Dec 9, 2011 at 4:54pm
Dec 9, 2011 at 5:29pm
You must never distribute DEBUG versions.


Why not? I know a number of programs that have dist versions with debug symbols. Or is this a Visual Studio thing?
Dec 9, 2011 at 5:44pm
It's a Microsoft VS thing...
Dec 9, 2011 at 5:48pm
What I meant by DEBUG is not the DEBUG you are probably thinking about. Also note that you can produce debug symbols for the release version of your binary. It is a linker option. I think VS2010 has this on by default. I think.

In any case, my advise was a simplistic one so as to not overwhelm the OP. Technically speaking you can pass a debug build to another person if you know exactly what you are doing. For example, if the debug build is not statically linked to the CRT, then you cannot make it work in another PC without the version of Visual Studio that you used, even if you install the C++ runtime in that PC because the debug version is not redistributable.

Also debug builds enable extra memory allocation and assert statements that overcomplicate the final version.

And I think that's about it.
Dec 9, 2011 at 6:59pm
Sounds like a Visual Studio thing, then. In my line (using mostly gcc and llvm) the debug version is just the name people commonly give to the one with zero optimisation and debug symbols included.
Last edited on Dec 9, 2011 at 7:00pm
Dec 9, 2011 at 7:31pm
/MT switch is for static release build and it will work in every PC (no runtime needed).
If you get linker errors, then rebuild your project or compile all your depedencies using the same linker switch.
Dec 10, 2011 at 10:19am
Thanks very much everyone, I tried it this morning and it worked :D
Topic archived. No new replies allowed.