How to get GLUT code running via xCode?
I'm having trouble writing C code with Glut with XCode. The main.c file compiles with no errors, but the 'black icon' file required to 'execute' the same is in red and gives the following errors. All help is very much appreciated.
<code>
Building target “cs6bz9lx01_drawing” of project “cs6bz9lx01_drawing” with configuration “Debug” — (11 errors)
cd /Users/gabriele/Documents/Personale/UNIBZ/cs6bz9/cs6bz9lx/cs6bz9lx01_drawing
setenv MACOSX DEPLOYMENTTARGET 10.5
/Developer/usr/bin/gcc-4.0 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk -L/Users/gabriele/Documents/Personale/UNIBZ/cs6bz9/workspace/Debug -F/Users/gabriele/Documents/Personale/UNIBZ/cs6bz9/workspace/Debug -filelist /Users/gabriele/Documents/Personale/UNIBZ/cs6bz9/workspace/cs6bz9lx01 drawing.build/Debug/cs6bz9lx01_drawing.build/Objects-normal/i386/cs6bz9lx01drawing.LinkFileList -mmacosx-version-min=10.5 -o /Users/gabriele/Documents/Personale/UNIBZ/cs6bz9/workspace/Debug/cs6bz9lx01_dra wing
Undefined symbols:
"_glEnd", referenced from:
_drawGLScene in main.o
"_glFlush", referenced from:
_drawGLScene in main.o
"_glutDisplayFunc", referenced from:
_main in main.o
"_glutMainLoop", referenced from:
_main in main.o
"_glClearColor", referenced from:
_drawGLScene in main.o
"_glColor3f", referenced from:
_drawGLScene in main.o
"_glBegin", referenced from:
_drawGLScene in main.o
"_glVertex2f", referenced from:
_drawGLScene in main.o
_drawGLScene in main.o
_drawGLScene in main.o
_drawGLScene in main.o
"_glutInit", referenced from:
_main in main.o
"_glutCreateWindow", referenced from:
_main in main.o
"_glClear", referenced from:
_drawGLScene in main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
"_glEnd", referenced from:
_drawGLScene in main.o
"_glFlush", referenced from:
_drawGLScene in main.o
"_glutDisplayFunc", referenced from:
_main in main.o
"_glutMainLoop", referenced from:
_main in main.o
"_glClearColor", referenced from:
_drawGLScene in main.o
"_glColor3f", referenced from:
_drawGLScene in main.o
"_glBegin", referenced from:
_drawGLScene in main.o
"_glVertex2f", referenced from:
_drawGLScene in main.o
_drawGLScene in main.o
_drawGLScene in main.o
_drawGLScene in main.o
"_glutInit", referenced from:
_main in main.o
"_glutCreateWindow", referenced from:
_main in main.o
"_glClear", referenced from:
_drawGLScene in main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Build failed (11 errors)
#include <stdio.h>
#include <GLUT/GLUT.h>
void drawGLScene(){
glClearColor(1,1,1,0); // white background color (0,0,0,0) is black
glColor3f(0,0,0); //drawings past this will be in black
glClear(GL COLOR_BUFFERBIT); // clears the screen with the selected background color (was 7th line)
glBegin(GL LINESTRIP); //glBegin(...) starts drawing the parameter, GL LINESTRIP means that points defined afterwards shall be joined by straight line
glVertex2f(-0.5,0.0); //defines vertex at x = -0.5 and y = 0,0;
glVertex2f(0.5,0.0);
glVertex2f(0.0,0.7);
glVertex2f(-0.5,0.0);
glEnd(); //stop drawing
glFlush(); //draws objects defined above on to the screen
// glutPostRedisplay(); start drawing again (animation)
}
int main (int argc, char **argv) {
glutInit(&argc, argv); // initializes glut and starts using it
glutCreateWindow("Simple OpenGL Example");
glutDisplayFunc(drawGLScene); //draw as per function above
glutMainLoop(); // loop for keep on drawing.
return 0;
}
</code>
Macbook, Mac OS X (10.5.5)