CS 450 / 550 -- Running the sample.cpp Program on a Mac


This page was last updated: September 22, 2017


Thanks to alert student Adrian Bloomer, we have the following:

Both OpenGL and GLUT are included in OSX by default so you don't need to install anything. But, in the sample.cpp program, you need to change these #include lines:


#include <GL/gl.h>
#include <GL/glu.h>
#include "glut.h"
to these:

#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>

Additionally, you need to pass the compiler flags -framework OpenGL -framework GLUT to g++.

So, the Makefile would look something like this:


sample:
	g++  -o  sample    sample.cpp    -lm  -framework  OpenGL  -framework  GLUT

On top of that, it is useful to pass the flags
-Wno-deprecated-declarations -Wno-c++11-compat-deprecated-writable-strings
in order to silence warnings that are caused by code in sample.cpp and in glut.h.