Setup and Use GCC on Windows in 5 Easy Steps

Do you want to be able to compile C, C++, Ada and Fortran programs on Windows without losing time wrestling with a bulk, resource-intensive IDE? You can! The solution is to port the ultra-popular, lightweight GCC (GNU Compiler Collection) often used in *nix systems to Windows via MinGW + Cygwin.

MinGW is the minimalist GNU implementation for Windows.

If you’re like me then by the time you’ve come to the realization that you want to use MinGW and GCC on Windows for coding purposes, you’ve probably already installed it as a dependency of other software you might run, such as Anaconda or along with your Cygwin install (if so, skip to Step 3).

1. Install Cygwin, which provides many Linux commands/libraries to Windows

2. Install MinGW

3. Make sure that MinGW was added to your PATH by typing PATH in a terminal

If not, you can add it through Window’s GUI interface (just type PATH or Environment in Start on Win 7 or 8 and it will come right up as a search result).

4. In a terminal (cmd or PowerShell) go to the directory containing the code you want to compile, i.e.

cd c:\Users\Hackr\coolcode

5. Type the compile command:

g++ hackr.c -o hackr.exe

where -o is indicating your output file.

This also works with compiling multiple files:

g++ hackr.c econometrics.c hadoop.c overflow.c -o hackeconometrics.exe
That’s it!

This should take at least an hour or 2 less time than installing Microsoft’s Visual Studio (though the latter has it’s virtues) or a similar bulky IDE and will give you fewer headaches by avoiding complicating your life with a million unnecessary options and confusing attempts to “help” you build a simple project.