My friend wanted me to make him this program and he is not very tech savvy. How can I make the .exe run without making him download anything extra? It was coded in C++ on Visual Studio.
-
Nope, you need to distribute the runtime. – Feb 04 '15 at 04:29
-
So what have you done so far? – SiKing Feb 04 '15 at 04:33
-
You can link everything statically, but then the executable can get a bit large. – Cheers and hth. - Alf Feb 04 '15 at 04:57
-
Well is there another file type I can convert it to? Like .iso? I don't necessarily need it to be an .exe but I want it to run in the command prompt and function as it is intended. – Feb 04 '15 at 17:46
1 Answers
If your program uses anything from the standard library, it will need the Visual C++ runtime library, which is typically loaded from the library DLLs (something like msvcr110.dll
).
However you can instruct the compiler (the linker, rather) to include (I do not mean #include-ing the header file) the library as part of your executable (exe
file). (I guess you thought of ISO because an archive file would include all the necessary DLLs) According to https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx, use the /MT compiler option will cause the "multithreaded, static version" of the Visual C++ runtime library (which is the library in pre-compiled code) to be included in your program during linking (in contrast to the default /MD option, which only causes code that helps your program link to the main library DLL to be included).
Correction: The program will be larger, but since the linker does not actually add everything to the output program, the size of the output file depends on what the program uses. Microsoft Visual Studio ~ C/C++ Runtime Library ~ Static/dynamic linking This might be helpful. (If you are interested, look into Program Files (x86)\Microsoft Visual Studio 12.0\VC\lib
(don't forget to replace the version number).)
Go to project settings -> configuration properties -> C/C++ -> code generation and set runtime library
to Multi-threaded (MT)
.
Correction: it seems directly setting the compiler flag will work even with the default /MD or /MDd flag left in the command line.
EDIT: be sure to clean the solution (build -> clean solution) after applying these settings. Otherwise the linker may still try to use the old files.

- 1
- 1

- 159
- 1
- 10