newbie question

im trying to compile

gcc … -L/usr/X11R6/lib -lGL -lGLU -lglut

and i get errors like" undefined reference to glXQueryExtension" ect…

hmm i really dont know whats wrong. Any help would be appriciated.

Could you copy and paste the exact command line you use and the exact errors you get?

From what you posted it looks like you’re doing everything OK.

<code>
[root@knavely proj]# gcc hmm.c -L/usr/X11R6/lib -lGL -lGLU -lglut
/usr/X11R6/lib/libglut.so: undefined reference to glXQueryExtension' /usr/X11R6/lib/libglut.so: undefined reference toglXMakeCurrent’
/usr/X11R6/lib/libglut.so: undefined reference to glXQueryExtensionsString'/usr/X11R6/lib/libglut.so: undefined reference toglXChooseVisual’
/usr/X11R6/lib/libglut.so: undefined reference to glXDestroyContext' /usr/X11R6/lib/libglut.so: undefined reference toglXWaitX’
/usr/X11R6/lib/libglut.so: undefined reference to glXQueryVersion' /usr/X11R6/lib/libglut.so: undefined reference toglXGetClientString’
/usr/X11R6/lib/libglut.so: undefined reference to glXIsDirect' /usr/X11R6/lib/libglut.so: undefined reference toglXSwapBuffers’
/usr/X11R6/lib/libglut.so: undefined reference to glXCreateContext' /usr/X11R6/lib/libglut.so: undefined reference toglXGetConfig’
collect2: ld returned 1 exit status
</code>

thats what happens when i compile heres the program.
<code>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <GL/glut.h>
#include <stdlib.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)
{
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(250,250);
glutInitWindowPosition(100,100);
glutCreateWindow(“hello”);
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
</code>

That’s pretty odd. What distro are you using?

You might try:

-lglut -lGLU -lGL

or

-lglut -lGLU -lGL -lX11

or

-lglut -lGLU -lGL -lXext -lX11

Let me know which one works

using mandrake 7.2

in the first one i got different/more of the same errors
the second/third user/bin/ld "cannot find -lX11
and in the fourth " cannot find -lXext

Strange.

I also use Mandrake 7.2, and all I need is
the following:

-L/usr/X11R6/lib -lGL -lGLU -lglut

Couldn’t find -lX11??? That’s not good… it should be in /usr/X11R6/lib, which you specify on the command line.

Uhm… what do

$ rpm -q XFree86

and

$ rpm -q Mesa

tell you?

thanks alot for your help

i got it working…i reinstalled xfree86-dev pkg and now iv got my hello box.

thanks again

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