Setting up MinGW in Windows 7 to compile adequately portable C++ code
compilation, mingw, path, windows
Solution
All you need to do for your exe to work is either put the GCC DLLs somewhere in PATH (by adding `C:\MinGW\bin` to your PATH) or compile all your code to link statically to the GCC runtime DLLs by using "-static" as a linker argument. When you distribute your executable, you'll need to make sure libgcc*.dll and libstdc++-6.dll are both installed alongside your executable. (if you're still using MinGW.org's toolchain, time to step up to MinGW-w64, who don't have a `mingwm10.dll` or whatever it's called).
The GCC DLLs are much the same as Visual Studio's C++ redistributables; to run code built with a certain VS version, you need the DLLs. Linking statically is the only way to not have that problem.
Also, get a cross-platform build system like CMake. It will make your life a lot easier.
Problem
Preface: I have been really turned away from writing and learning C/C++ in Visual Studios and Windows with the way things are compiled and worked with. I much prefer Ubuntu with vim and g++ but I want to have In addition to that a good Windows based work environment set up. Question: Basically I am learning C++ with Notepad++ and looked into MinGW to be my compiler. I am having a hard time finding good answers on to how best go setting it up, and all the minutia involved in compiling code, and how it becomes dependent on MinGW's dll files. It seems I have to set up Paths to compile outside of the C:\MinGW\bin folder, but even then I am forced to execute the program in that very same folder. Otherwise I get an error that I am missing a dll. While not only is this a hassle for actual development(don't say move to Linux, read the pre-face) but It prevents my code from having any sort of portability to other windows systems. Perhaps I lack knowledge on how to correctly create executables and package their files with installers. If thats what I need to learn then perhaps point me in the right direction.