Hey guys,
I'm stuck on some undefined references to glut and OpenGL, even when I linked my projects with the correct libraries. Well apparently they aren't correct...
I'm trying to compile this:
/* Copyright (c) Mark J. Kilgard, 1994. */
/* This program is freely distributable without licensing fees
and is provided without guarantee or warrantee expressed or
implied. This program is -not- in the public domain. */
#include <GL/glut.h>
GLfloat light_diffuse[] =
{1.0, 0.0, 0.0, 1.0};
GLfloat light_position[] =
{1.0, 1.0, 1.0, 0.0};
GLUquadricObj *qobj;
void
display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glCallList(1); /* render sphere display list */
glutSwapBuffers();
}
void
gfxinit(void)
{
qobj = gluNewQuadric();
gluQuadricDrawStyle(qobj, GLU_FILL);
glNewList(1, GL_COMPILE); /* create sphere display list */
gluSphere(qobj, /* radius */ 1.0, /* slices */ 20,
/* stacks */ 20);
glEndList();
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
gluPerspective( /* field of view in degree */ 40.0,
/* aspect ratio */ 1.0,
/* Z near */ 1.0, /* Z far */ 10.0);
glMatrixMode(GL_MODELVIEW);
gluLookAt(0.0, 0.0, 5.0, /* eye is at (0,0,5) */
0.0, 0.0, 0.0, /* center is at (0,0,0) */
0.0, 1.0, 0.); /* up is in positive Y direction */
glTranslatef(0.0, 0.0, -1.0);
}
int
main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutCreateWindow("sphere");
glutDisplayFunc(display);
gfxinit();
glutCreateWindow("a second window");
glutDisplayFunc(display);
gfxinit();
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}
And added these options to the linker (according to code::blocks):
-lopengl32
-lglu32
-lglut32
And getting these errors:
.objs\drivertest.o:drivertest.cpp:(.text+0x1c)||undefined reference to `__glutInitWithExit'|
.objs\drivertest.o:drivertest.cpp:(.text+0x37)||undefined reference to `__glutCreateWindowWithExit'|
.objs\drivertest.o:drivertest.cpp:(.text+0x53)||undefined reference to `__glutCreateMenuWithExit'|
.objs\drivertest.o:drivertest.cpp:(.text+0x68)||undefined reference to `_imp__glClear'|
.objs\drivertest.o:drivertest.cpp:(.text+0x76)||undefined reference to `_imp__glCallList'|
.objs\drivertest.o:drivertest.cpp:(.text+0x7d)||undefined reference to `glutSwapBuffers'|
.objs\drivertest.o:drivertest.cpp:(.text+0x8b)||undefined reference to `_imp__gluNewQuadric'|
.objs\drivertest.o:drivertest.cpp:(.text+0xa7)||undefined reference to `_imp__gluQuadricDrawStyle'|
etc.
Any clues?
Thanks in advance,
Nick