C++ Resources

Updated on January 7 2017




Deborah R. Fowler



GNU compiler on Windows for C++

Updated on  Feb 25  2014
Updated on  Feb 19  2015

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:

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
    In addition, if you intend to use make files on your windows systems, scroll toward the bottom and also click the last two entries as they also default to off.
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 7 you need to:
        - double click on the computer icon, and at the top context menu choose System Properties
        - click on the left menu item, Advanced system settings which brings up a dialog box
        - in the lower right corner, click Environment Variables
        - edit the "path" under "System variables" to include C:\MinGW\bin;
5. Now bring up a cmd window and type in c++ -v and you will see it indicates it is using gcc version 4.6.2 (in my case)

Troubleshooting:

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.
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 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