You are not logged in.

#1 2006-01-24 21:30:32

Southern_Trendkiller
Member
Registered: 2005-09-27
Posts: 31

C++ OpenGL compile problem

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

#2 2006-01-24 21:52:26

leeghoofd
Member
From: the Netherlands
Registered: 2005-04-28
Posts: 61

Re: C++ OpenGL compile problem

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

#3 2006-01-25 06:13:55

Southern_Trendkiller
Member
Registered: 2005-09-27
Posts: 31

Re: C++ OpenGL compile problem

uhh sorry, i can't see the doublepost  :shock:

Your commandline worked smile thank you very much.
Maybe you could explain what -lXmu and -lxi do?

Offline

#4 2006-01-25 09:26:21

leeghoofd
Member
From: the Netherlands
Registered: 2005-04-28
Posts: 61

Re: C++ OpenGL compile problem

Hi,

I can't see your double post too anymore, probalby a moderator removed it. smile

-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. smile

David

Offline

Board footer

Powered by FluxBB