Compiling GLUT in Linux

This is just a quick supplement to my post on OpenGL on OSX.

To get the same code running under Linux, I simply changed the includes to the following:

#include <GL/glut.h>
#include <GL/gl.h>

…and compiled the code using the following line in the terminal:

gcc glutTest.c -lGL -lGLU -lglut

(Note that I’m using gcc because I’m now compiling a .c file. If it were a .cpp file, I would use g++ instead)

If you’re getting errors such as ” has incomplete type” or “invalid use of GLvoid”, simply replace all instances of GLvoid with just void, and it should work.


OpenGL on OSX with GLUT and G++

There’s no doubt that programming with an IDE saves you loads of time with convenience, and ease-of-use. As programmers, we don’t always have the luxury of having a program do all the nasty bits for us, so it’s always good to learn how to program in a text editor (Emacs is a great choice) and how to compile from the command line.

Personally, I like programming in an environment that doesn’t require a lot of overhead, gives me a large amount of control, and lets me see all the little details. I’m going to give a startup tutorial for programming OpenGL with GLUT on OSX (Version 10.5.7), and I’ll be using nothing but GNU Emacs, and g++ (which is an optional install on your OSX Install DVD). More after the jump.

Continue reading