Installing OpenGL and GLUT on a Mac?

Does anyone know how exactly I’d do this? I’ve been reading up, and everything seems to point to the apple website. I’ve downloaded what people said to download, but it doesn’t seem to have anything I can actually INSTALL with, just things that I’m supposed to install somehow. Try as I might, I haven’t been able to find a guide that actually explains how I’m supposed to get it all working. Does anyone know?


I program opengl on my powerbook and it required no setup… opengl & glut are already installed with the operating system… you just need to include it in your projects.

According to the tutorial I’ve been working with, all I had to include was

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include "tk.h"  

But that doesn’t seem to work. Do I have to compile it some special way or something? Termain commands like “which glut” and “which opengl” return nothing, so I’m not 100% sure they’re already installed.

When I try to compile code with those includes, it throws an error about the files I’m including not existing.


I believe you used a windows guide.

change that to say
#include <GLUT/glut.h> // thats it

And in xcode you need to set up a package to include OpenGL.framework and GLUT.framework
Right-click the project file in xcode and click add frameworks… and browse to them

Yes, you do not need those other headers you previously posted (gl.h, glu.h).

And when you are creating an Xcode project, the easiest way to do it is create an empty project, add a Carbon target, add all your source code files, then add the frameworks “Cocoa”, “GLUT”, and “OpenGL”, and then you’re set to go!

Also, you can follow the NeHe tutorial found on my website (once you’ve done that, you can move right on to NeHe lesson 2):
(sometimes it’s down because of excess traffic, so if that happens, try again later)

it was a NeHe tutorial in the first place…must have clicked the wrong one. I’m using Smultron for my editing though, is there anything different I need to do because of that?


Sorry for the double post, but I’ve edited the file and tried compiling, only to get these errors:

/usr/bin/ld: Undefined symbols:
ReSizeGLScene(int, int)
collect2: ld returned 1 exit status

I don’t know DrawGLScene() to be a function of OpenGL… that’s something you need to define… (i could be wrong on that)

int main (int argc, char **argv) {
glutInit (&argc, argv);
glutInitWindowSize (1024, 640);
glutInitWindowPosition (100, 100);
glutCreateWindow ("");
glutDisplayFunc (display);
glutIdleFunc (display);
glutReshapeFunc (reshape);
glutMainLoop ();
return 0;

After changing the main() block to what you suggested, it threw these errors:

 test.cpp: In function 'int main(int, char**)':
test.cpp:24: error: 'init' was not declared in this scope
test.cpp:25: error: 'createLights' was not declared in this scope
test.cpp:26: error: 'display' was not declared in this scope
test.cpp:28: error: 'reshape' was not declared in this scope 

again, those are functions that you have to write yourself… i cant write the entire program for you… thats just a skeleton…
init, createLights, display, and reshape are all things that you need to write somewhere else… (createLights is optional)

After messing around with it for a while, I’ve still managed to get it to throw these errors:

 /usr/bin/ld: Undefined symbols:
collect2: ld returned 1 exit status 

It seems to throw them when all the other code is correct, as a parting shot or something.


That means that everything is now compiling. You need to add ‘-framework OpenGL -framework GLUT’ to your compile command to allow the linker to find those functions.

That’s solved the problem. Thanks!