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)

UPDATE:
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.

Advertisements

2 thoughts on “Compiling GLUT in Linux

    • Glad it helped! I remember it took me a while to figure it out, so I wanted to post it here, both for my own reference, and also in case it helped anyone else! 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s