-1
I've got a C++ program that I can compile and run on Mac OS 10.11 using g++. I also was able to compile and run it on Windows 10 using Visual Studio. However, when I tried to run the .exe file on a Windows 10 computer that did not have Visual Studio installed, Windows complained that several .dll files didn't exist.
I'd like to be able to run this program on Windows computers without requiring any installation of anything. The program is very simple, consisting of one .cpp file, and only lives in a text-only terminal. All it does is ask for input, display some text, and write to a file. I'm using these libraries:
#include <stdlib.h>
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
I also tried MinGW both in Cygwin, and on OS X. Both give errors about ‘stoi’ was not declared in this scope
. I tried this patch unsuccessfully: https://stackoverflow.com/questions/16132176/problems-with-stdstoi-not-working-on-mingw-gcc-4-7-2 I don't know if MinGW would make my .exe independent of other files.
How can I make my program run self-contained on Windows, so it doesn't require any the user to install any .dll files or other software?
What you desired requires using a compiler that allows that or provide the dll files with the .exe itself. "so it doesn't require any .dll files or other software?" literally not possible. – Ramhound – 2016-01-15T18:51:08.683
I don't understand how it could be "literally not possible". There are plenty of Windows programs (especially MS-DOS programs) that don't require users to install anything aside from Windows itself. Maybe you thought I was saying that I want it to not require literally any other software. I made an edit to be explicit that I don't want the user to need to install any software, but of course Windows is there along with its standard .dll files. – aswine – 2016-01-15T18:56:38.870
You likely need to ensure that the Visual C++ Redistributables are installed on the other computer (can download from MS site). I presume it is complaining about MSVCR100.dll or something similar. – Tom Carpenter – 2016-01-15T18:56:40.453
1
See this StackOverflow question for how to statically link the runtime library so you don't need the redistributable installed.
– Tom Carpenter – 2016-01-15T18:59:13.897If you link a library at compile time, which you have done, then that library is required on the system the executable will be run on. MS-DOS programs are not Windows programs. If your program didn't require additional libraries what you described would have worked, since it did require them, it means you linked to the libraries and thus they are needed. – Ramhound – 2016-01-15T19:05:43.083
Apparently it's not impossible, because other people are talking about having done it. http://stackoverflow.com/questions/16167305/why-does-my-application-require-visual-c-redistributable-package I just need to statically link them, rather than dynamically link them. A downvote explanation would be nice, by the way.
– aswine – 2016-01-15T19:40:36.953You state that "Windows complained that several .dll files didn't exist." It would be helpful for us to have the entire list of missing DLLs. – BillP3rd – 2016-01-15T19:58:45.900
It was issued on the grounds this is far to close to a programming question which belongs SO for my personal tastes. I don't know why I am sharing my reason, I know you won't agree with it, and likely will present some sort of argument on how I am wrong. – Ramhound – 2016-01-15T20:11:23.853
@aswine - Point of clarification. What I said was not possible is to dynamically link a library and then not install the required software. Even if you statically link the required libraries, you still have to provide them, which basically means your software must install those libraries on the system thus increasing the size of your installer. I just indicated what you wanted, "so it doesn't require any .dll files or other software?", wasn't possible for that reason. – Ramhound – 2016-01-15T20:15:52.493