Undefined References

We are trying to get Open GL / GLUT working, but are not having success with either. We are attempting to create a simple ploygon (a triangle), but get a bunch of undefined reference errors.

the following is our code:
#include <GL/gl.h>
#include <GL/glut.h>
#include <stdlib.h>

void init(void){
glClearColor(0.0, 0.0, 0.0, 0.0);
}

void display(void) {

glColor3f(1.0,1.0,1.0);

glBegin(GL_POLYGON);
glVertex2f(0.0,0.0);
glVertex2f(1.0,0.0);
glVertex2f(0.0,1.0);
glEnd();
}

int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(400,150);
glutInitWindowPosition(100, 100);
glutCreateWindow(argv[0]);
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}

and here are the error messages:

[clio@babbage 3D]$ gcc poly.c
/tmp/ccM3hqwK.o: In function init': /tmp/ccM3hqwK.o(.text+0xf): undefined reference to glClearColor’
/tmp/ccM3hqwK.o: In function display': /tmp/ccM3hqwK.o(.text+0x31): undefined reference to glColor3f’
/tmp/ccM3hqwK.o(.text+0x3e): undefined reference to glBegin' /tmp/ccM3hqwK.o(.text+0x4d): undefined reference to glVertex2f’
/tmp/ccM3hqwK.o(.text+0x5f): undefined reference to glVertex2f' /tmp/ccM3hqwK.o(.text+0x71): undefined reference to glVertex2f’
/tmp/ccM3hqwK.o(.text+0x79): undefined reference to glEnd' /tmp/ccM3hqwK.o: In function main’:
/tmp/ccM3hqwK.o(.text+0x93): undefined reference to glutInit' /tmp/ccM3hqwK.o(.text+0xa0): undefined reference to glutInitDisplayMode’
/tmp/ccM3hqwK.o(.text+0xb5): undefined reference to glutInitWindowSize' /tmp/ccM3hqwK.o(.text+0xc4): undefined reference to glutInitWindowPosition’
/tmp/ccM3hqwK.o(.text+0xd4): undefined reference to glutCreateWindow' /tmp/ccM3hqwK.o(.text+0xe9): undefined reference to glutDisplayFunc’
/tmp/ccM3hqwK.o(.text+0xf1): undefined reference to `glutMainLoop’
collect2: ld returned 1 exit status

If anyone could give us a hand, that would be great.

ciao

joe

gcc -o poly poly.c -L/usr/X11R6/lib -lGL -lGLU -lglut

should probably do it.

[This message has been edited by rts (edited 05-23-2001).]

Thank you, that worked absolutely perfectly.

Thank you too, it’ solved my (same) problem

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.