C++ Resources

Updated on January 7 2017



C++CompilersCommandLineIDEsQuickSummary

Deborah R. Fowler



Summary Table for C++     ...   including Makefiles

Posted on  July 28  2013
Updated Jan 7  2017

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

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

SUMMARY
On Windows
with OpenGL/glut
...freeglut
On Linux
with OpenGL/glut
...freeglut
Visual Studios 2015
here
VS 2010 with OpenGL/glut here
VS with freeglut
n/a
n/a
n/a
Eclipse
Eclipse on Windows
(see Eclipse on Windows)

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

Geany on Linux
(see Geany on Linux)
tba
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
same
linux with freeglut
Makefile
mingw32-make
(example for tank)
(example for tank)
example zip
make
(example for tank - linux)
same

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;
#endif

** 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/)


Makefiles

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.