i am using c++ as
the programming language. i am a new user in open gl
and glut. wrote the following code and tried to
compile it with the following command:
g++ -o hi hi.cpp -L/usr/X11R6/lib -lGLU -lGL -ldl -lSM -lICE -lXi -lXmu -lXext -lX11 -lm
my code is as follows:
#include<GL/gl.h>
#include<GL/glut.h> void display(void)
{
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(void)
{
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);
}
int main (int argc, char** argv)
{
glutInit (&argc, argv);
glutInitDisplaymode (GLUT_SINGLE | GLUT_RGB );
glutInitWindosize (250,250);
glutInitWindowPosition (100,100);
glutCreateWindow (“hello”);
init();
glutDisplayFunc(display);
void glutmainLoop(void);
return 0;
}
i got the following errors:
tmp/cc7rePCk.o(.text+0x169): In function main': : undefined reference to
glutInit’
/tmp/cc7rePCk.o(.text+0x176): In function main': : undefined reference to
glutInitDisplayMode’
/tmp/cc7rePCk.o(.text+0x18b): In function main': : undefined reference to
glutInitWindowSize’
/tmp/cc7rePCk.o(.text+0x19a): In function main': : undefined reference to
glutInitWindowPosition’
/tmp/cc7rePCk.o(.text+0x1aa): In function main': : undefined reference to
glutCreateWindow’
/tmp/cc7rePCk.o(.text+0x1bf): In function main': : undefined reference to
glutDisplayFunc’
i had got a similar problem when i had started working
with c++ on suse 9.1.
then i was getting error as
cout undefined. definre it first.
i addded the folowing line to my code
#using namespace std;
//std::cout
please help me solve my problem.
waiting for you reply
vijay rana