C++ Resources

Updated on January 7 2017

Deborah R. Fowler

GNU compiler on Windows for C++

Updated on  Feb 25  2014
Updated on  Dec 1  2017

Installing the GNU compiler on Windows:

If you do not wish to use an IDE such as Visual Studios, you can also compile in a more "linux like" manner on windows using the gnu compiler.

To install this (modified from Page 11 of C++ Programming in easy steps) do the following (tested again on Windows 10 personally 12/1/2017):

1. Go to sourceforge.net/projects/mingw
2. Hit the "Download" green button
3. Save and launch the file to install but be sure to select "C++ Compiler" as it defaults to off under Select Components
4. Include the path on windows, and you can then use the gnu-compiler in a command prompt (cmd) window
     NOTE: To include the path on Windows 10 you need to:
5. Now bring up a cmd window and type in c++ -v and you will see it indicates it is using gcc version 6.3.0 (in my case)


If you see libgmp-10.dll is missing make sure you have checked that base as well as the C++ option are installed:

Test your compiler by using a simple hello world example. Puruse to the directory (cd to the path of where the files lives). Ms-Dos is similar to linux, however dir is used instead of ls to list files
ie. in any text editor save a file labeled helloworld.cpp with the following content:

Using the GNU compiler on Windows:

// C++ Hello World Example Program
#include <iostream>
using namespace std;

int main()
    cout << "Hello World" << endl;
    return 0;

To compile this, start a command prompt window and type c++ helloworld.cpp -o helloworld.exe
Run helloworld.exe or simply helloworld

Using the GNU compiler with a Makefile

You could also compile using a Makefile by running the command mingw32-make with a Makefile in the directory. A simple makefile would look as follows (note the white space is a TAB). Typing mingw32-make would execute the command line.

hello: helloworld.cpp
    c++ -o helloword helloworld.cpp

Using the GNU compiler on Windows with OpenGL/glut:

This is fairly straightforward once you have the MinGW files set up properly. Click here.
c++ test.cpp -o test.exe -lopengl32 -lglu32 -lglut32