C++ Resources

Updated on January 7 2017


Deborah R. Fowler

Summary Table for C++     ...   including Makefiles

Posted on  July 28  2013
Updated Jan 14  2018

Freeglut for Windows has been added to be consistent with our setup. I have tested it offsite with VS 2015
Professional, VS 2017 Community Versions and MinGW.
Currently glut is still used on linux.

Compilers/Command Line/IDE Summary Table (for more discussion see C++ Resources):

On Windows
with OpenGL/glut
On Linux
with OpenGL/glut
Visual Studios 2015
or VS 2017
VS 2010 with OpenGL/glut here
VS with freeglut
Eclipse on Windows
(see Eclipse on Windows)

Eclipse on Linux
(see Eclipse on Linux)
Geany on Windows
(see Geany on Windows)

Geany on Linux
(see Geany on Linux)
Command Line
c++ test.cpp -o test.exe
more about GNU here

** see note below
c++ test.cpp -o test.exe -lopengl32 -lglu32 -lglut32
more about OpenGL/glut here
mingw with freeglut
g++ test.cpp -o test.exe

** see note below
g++ test.cpp -o test.exe -lGL -lGLU -lglut
more about OpenGL/glut here
linux with freeglut
(example for tank)
(example for tank)
example zip
(example for tank - linux)

A simple "hello world" makes a great test (see here).
I have also provided an example to test your OpenGL/glut set up here.

This is the same table provided on the C++ Resources page but is provided here for quick click convenience. I have personally tested all the combinations listed above either at Monty or on my home computer.

** Proper Usage Tip: you may want to add the flags  -pedantic -Wall        as well.
See note about wrong use of Arrays (use vectors if you want dynamic allocation).

** Troubleshooting Tip: note if you use the type numeric_limits in visual studios the compiler will recognize it, but command line (linux or mingw on windows) you will need to #include <limits>

** Troubleshooting Tip: M_PI is defined in "math.h" on linux, however it depends on which compiler you are using on Windows. If you are using mingw32-make in a command window it will recognize it, however Visual Studios Win32 project will not. You can test it on your own machine with this sample file here. One way to handle this is to add a define with an ifndef statement:
#ifndef M_PI
#define M_PI 3.141592654;

** Troubleshooting Tip: if you are splitting out your files into classes are are not using an IDE, please remember to use the #ifndef / #define / #endif syntax in your .h files and/or #pragma once. There is an excellent explanation here.
Some programmers believe it is safest to use both (see bottom of the thread here).

** Troubleshooting Tip: If you are using freeglut on Windows do not use the variable names far or near (http://sourceforge.net/p/freeglut/bugs/205/)

** Troubleshooting Tip: If you should ever need to run Visual Studios without a shortcut:
2015 at Monty is in C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe
2017 on your Home Computer lives in C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE and you can use the CMD window to cd to that path and run devenv.exe


With respect to makefiles, most IDEs have functionality that does not require you to create a makefile, however this becomes necessary if you are using multiple files with Geany. There is an excellent tutorial on Makefiles here. I have also provided an example make file above for both Windows and Linux for the OpenGL_TankTemplate starter game in the dropbox. There are step by step makefiles in the dropbox as well.