How to install and use Minimalist GNU for Windows (MINGW)


Minimalist GNU for Windows (MINGW)


MINGW is a collection of compilers for languages such as C++, C, ADA and Fortran. This will allow you to compile scripts from these languages into usable programs.

You can get the latest update of the installer for Windows from Sourceforge here.

Install the software to the required settings, this will be different per user and may need to be looked on their wiki site to understand them all.
Find where the program was installed and then go into the "bin" folder inside that area, then copy the directory path as it will be needed later. At this point, go to "Control Panel", then "System and Security", then "System".On the left hand side click "Advanced system settings".
From here click "Environment Variables...". On the lower half of the box there is the System Variables, scroll through this list until you find "Path", click it and then click "Edit...". If it is not there (it should be), click "New..." instead. Either way, on the next box the "Variable name" should be "Path" and in "Variable value" the path to the previously mentioned directory should be pasted in there inside quotation marks. If there is already items in the value box, scroll to the end, put a semi-colon and the put the directory inside quotation marks. Click OK on every box to close them.

At this point, you can test if everything is done correctly by opening command prompt and typing "c++" then pressing enter. It should return an error about no input files being given. Otherwise something was done incorrectly.
If the correct error is given, you can now write your programs in a text editor, change the extension to the correct one for the language. To compile the file, open command prompt, type the required compiler name (like "c++") and then the path to the code. This will then output an "a.exe" file in the path the command prompt was open from.

From using this we found an error occurring when using it for c++ files.

"libstdc++-6.dll was not found"



From the following link we found that if you add the following into the command prompt when compiling the code, it compiles the dlls statically to avoid the error (Depending on C or C++).

For C: "-static-libgcc" and for C++: "-static-libstdc++"

Link to the solution by Kerrek SB