You are not logged in.
Pages: 1
Helly everybody,
I just recently got interested in the OpenGL API and decided to start code a bit. I'm also new to C++, just so you guys know.
When i try to compile a simple program on the shell, i get the following errors; Can anybody tell me why?
[trendkiller@CFH source]$ g++ glut1.cpp -o glut1 -lglut -lGLU -lGL -lX11 -lm -L/usr/X11R6/lib
glut1.cpp: In function 'int main(int, char**)':
glut1.cpp:25: warning: statement is a reference, not call, to function 'glutMainLoop'
/usr/X11R6/lib/libglut.so: undefined reference to `XGetExtensionVersion'
/usr/X11R6/lib/libglut.so: undefined reference to `XFreeDeviceList'
/usr/X11R6/lib/libglut.so: undefined reference to `XQueryDeviceState'
/usr/X11R6/lib/libglut.so: undefined reference to `XListInputDevices'
/usr/X11R6/lib/libglut.so: undefined reference to `XFreeDeviceState'
/usr/X11R6/lib/libglut.so: undefined reference to `XOpenDevice'
/usr/X11R6/lib/libglut.so: undefined reference to `XmuLookupStandardColormap'
/usr/X11R6/lib/libglut.so: undefined reference to `XSelectExtensionEvent'
collect2: ld returned 1 exit status
[trendkiller@CFH source]$
Here's the sourcecode of "glut1"
#include <GL/glut.h>
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f( 0.5, 0.5);
glVertex2f( 0.5, -0.5);
glEnd();
glFlush();
}
int main (int argc, char** argv)
{
glutInit(&argc, argv);
glutCreateWindow("simple");
glutDisplayFunc(display);
glutMainLoop;
}
Offline
Hi,
You need to add the inlcude for gl to, so add
#include <GL/gl.h>
to the top of the file.
Also you need to add () to the function call glutMainLoop, so change
glutMainLoop;
into
glutMainLoop();
Than you can compile it with this command:
gcc glut1.cpp -o glut1 -L/usr/X11R6/lib -lglut -lGLU -lGL -lX11 -lXmu -lXi
Your message is posted twice on this forum, could you please remove the other one to avoid duplicated answers?
Cheers,
David
Offline
uhh sorry, i can't see the doublepost :shock:
Your commandline worked thank you very much.
Maybe you could explain what -lXmu and -lxi do?
Offline
Hi,
I can't see your double post too anymore, probalby a moderator removed it.
-lXmu and -lXi link to those libraries just like -lglut and -lGL link to the glut and gl libraries. What they are exactly I don't know, but they are needed if you link to glut.
David
Offline
Pages: 1