I didn't get into the Computer Graphics class for next semester (

) so I'm going to teach myself opengl until can get into the class. I loaded up one of the early examples from the redbook and attempted to compile with gcc. (this is all happening on OSX 10.5.2)
Here's the ouptut
Code:
gcc hello.c
Undefined symbols:
"_glEnd", referenced from:
_display in ccAtIGKi.o
"_glFlush", referenced from:
_display in ccAtIGKi.o
"_glMatrixMode", referenced from:
_init in ccAtIGKi.o
"_glutDisplayFunc", referenced from:
_main in ccAtIGKi.o
"_glutMainLoop", referenced from:
_main in ccAtIGKi.o
"_glutInitDisplayMode", referenced from:
_main in ccAtIGKi.o
"_glutInitWindoePosition", referenced from:
_main in ccAtIGKi.o
"_glClearColor", referenced from:
_init in ccAtIGKi.o
"_glColor3f", referenced from:
_display in ccAtIGKi.o
"_glBegin", referenced from:
_display in ccAtIGKi.o
"_glVertex3f", referenced from:
_display in ccAtIGKi.o
_display in ccAtIGKi.o
_display in ccAtIGKi.o
_display in ccAtIGKi.o
"_glutInit", referenced from:
_main in ccAtIGKi.o
"_glOrtho", referenced from:
_init in ccAtIGKi.o
"_glLoadIdentity", referenced from:
_init in ccAtIGKi.o
"_glutCreateWindow", referenced from:
_main in ccAtIGKi.o
"_glClear", referenced from:
_display in ccAtIGKi.o
"_glutInitWindowSize", referenced from:
_main in ccAtIGKi.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
I'm pretty sure that I just have to use some command line linking options, but I have no idea what I need to link to or where the libraries would be located (I've never had to link to any external libraries - just additional pieces of provided code for classes)
Here's the code in case it helps
Code:
#include <stdio.h>
#include <stdlib.h>
#include <GLUT/glut.h>
/* function prototypes */
/* opengl std */
void display();
void init();
int main(int argc, char **argv){
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(250, 250);
glutInitWindoePosition(100, 100);
glutCreateWindow("hello");
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
void display(){
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f(0.25, 0.25, 0.0);
glVertex3f(0.75, 0.25, 0.0);
glVertex3f(0.75, 0.75, 0.0);
glVertex3f(0.25, 0.75, 0.0);
glEnd();
glFlush();
}
void init(){
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}