OpenGL in Mac OS X´s Terminal

Is it possible to program w/ OpenGL in Mac OS X´s Terminal?

Of course.

I assume that’s not what you really meant, though?

Related to this topic, but a bit more specific: How would one go about creating a makefile with which to properly link and compile OpenGL programs from the OS X terminal? I am familiar with makefiles on UNIX, but getting them to work on the Mac has been futile. Any advice would be appreciated.


The compiler is called cc rather than gcc or anything else. It is only installed when the developer tools are installed.

The files <GL/gl.h>, <GL/glu.h> and <GL/glext.h> are replaced by <OpenGL/gl.h>, <OpenGL/glu.h> and <OpenGL/glext.h>. This is “Framework include” syntax. The actual files are in /System/Library/Frameworks/OpenGL.framework/Headers/ . If you’re doing a large port, it may be easiest to make symbolic links to these in /usr/local/include/GL/ …

<GL/glut.h> is replaced by <GLUT/glut.h>, again a framework include.

Rather than the -lGL -lGLU you’re used to, you need -framework OpenGL

Rather than -lglut, you need -framework GLUT -framework Cocoa

GLUT.framework tries to set the cwd to the Resources folder inside your application bundle. I’ve had problems running un-bundled GLUT apps in the past, although I think this has been fixed since 10.1

make is in fact GNU make.


The easiest way to make OS X compile standard OpenGL source files is to write:
“sudo ln /System/Library/Frameworks/OpenGL.framework/Headers/ /usr/local/include/GL”

This should create a symlink (alias) to the OpenGL framework folder. You should now be able to compile OpenGL code written with or without the Framework doctrine in mind.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.