PDA

View Full Version : undefined reference to `gluOrtho2D'



junebird
03-04-2010, 04:59 AM
Hi all,
This is my first program to display a couple of points: what is wrong with it?
On doing below i get:
[surabhi@localhost ~]$ cc points.c -lglut
/tmp/cckmTBn0.o: In function `myinit':
points.c:(.text+0x10d): undefined reference to `gluOrtho2D'
collect2: ld returned 1 exit status

The program is as below.

#include<stdlib.h>
#include<GL/glut.h>

void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,0.0);
glBegin(GL_POINTS);
glVertex2f(10.0,10.0);
glVertex2f(150.0,80.0);
glVertex2f(100.0,20.0);
glVertex2f(200.0,100.0);
glEnd();
glFlush();
}

void myinit()
{
glClearColor(0.0,1.0,1.0,1.0);
glPointSize(10.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(.0,50.0,.0,50.0);
}

int main(int argc,char **argv)
{
glutInit(&amp;argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(300,200);
glutInitWindowPosition(0,700);
glutCreateWindow("points");
glutDisplayFunc(display);
myinit();
glutMainLoop();
return 0;
}


Do i need to reinstall opengl in my system (fedora)? i have tried installing many glut packages, but i still get this output.

dorbie
03-04-2010, 06:12 AM
Either include glu.h or try glOrtho and add near and far clip values.

ZbuffeR
03-04-2010, 06:18 AM
doing yum install freeglut-devel should be enough.

Then do not forgot to add -lGLU to your linker options too.

junebird
03-04-2010, 10:15 PM
hey guys thanks,adding -lGLU worked!!