Makefile with OpenGL/Glut

Home Research Publications Teaching Personal

Find your glut library

To know where to find glut.h (usually in /usr/lib/GL)
$ locate glut.h
$ find / -iname glut.h

(this directory should be added in the path with the flag -I/GLUT_DIRECTORY)

We take the case of this makefile, used for instance in this project.

Classical Linux systems

DIR_X = (usually ok, might try with -I/usr/X11R6/lib)
DIR_OPENGL = (usually ok, see where to locate glut.h)
FLAGS_X = (usually ok, might try with -L/usr/X11R6/lib -lX11 -lXext -lXmu -lXi)

See this exemple: test_make_linux.tar.gz


(see this tutorial)
Also need to run in cygwin-X ($ startx)

DIR_X = (usually ok, might try with
-I/usr/include and-or -I/usr/X11R6/include)
DIR_OPENGL = (usually ok, see where to locate glut.h)
FLAGS_X = -L/usr/X11R6/lib -lX11 -lXext -lXi -lXmu
FLAGS_OPENGL = -lopengl32 -lglu32 -lglut32

See this exemple: test_make_cygwin.tar.gz

Mac OsX

DIR_X = -I/usr/X11R6/include
DIR_OPENGL = -I/opt/local/include/GL
FLAGS_X = -L/usr/X11R6/lib -lX11 -lXext -lXi -lXmu
FLAGS_OPENGL = -L/opt/local/lib -lGL -lGLU -lglut


(see this tutorial)

Use to Glut-DevPak and start a Multimedia/glut project.
Or download glut, add glut.h and glut.lib into the project (glut.dll in the same directory) add the linkage parameters -lglut32 -opengl32 -lglu32 -lgdi32 -lwinmm

See this exemple: test_devcpp.tar.gz


If QT is installed, use qmake to build the makefile (cross-platform for linux/cygwin/...)

$ qmake
$ make

See this exemple: test_qmake.tar.gz