Can't find glDisable...

Hi all!
I’m new to OpenGL programming but I have a problem. I have to modify an existing project that makes use of OpenGL library. I had some problem trying to find the glut libriry, but I mahaged to and I compiled the project. Now when I try to execute the program it says that it can’t find the symbol glDisable. How is it possible? Why doesn’t it finds thelibrary? The compiler and the linker did, otherwise they would’nt compile or link…
Any Idea?

Thank you!

I think you’re perhaps a touch confused. You don’t get run-time exceptions like “can’t find glDisable”; this is a compiler error and means you forgot to include “gl.h” and/or forgot to link with opengl32.lib.

The exception to this might be some sort of C# framework that loads the core procs from opengl32.dll. In that case make sure the framework has been installed properly, and that your project has likewise been configured correctly.

I’m sure I get this error at runtime! As I said, it compiled and linked well, I added the glut.h file and the glut library to the linker arguments. As you may have noticed, I’m programming under Linux, so it’s not a C#`problem for sure! Thank for the help anyway! Any other ideas?

you can find out which libs a program needs by using ‘ldd’. for example:

ldd /usr/X11R6/bin/glxgears

will give an output like => /usr/lib/tls/ (0x40024000) => /usr/X11R6/lib/ (0x4008d000) => /usr/X11R6/lib/ (0x4009b000) => /lib/tls/ (0x4017a000) => /lib/tls/ (0x40187000) => /lib/tls/ (0x42000000) => /usr/lib/tls/ (0x401aa000) => /lib/ (0x40662000)
    /lib/ => /lib/ (0x40000000)

you’ll see if a library is missing.

then you can use readelf to check the library’s contents:

readelf -s /usr/lib/tls/ | grep glDisable

gives the output

879: 0004a1d0 0 FUNC GLOBAL DEFAULT 7 glDisable
2454: 0004a638 0 FUNC GLOBAL DEFAULT 7 glDisableClientState
2791: 0004bc28 0 FUNC GLOBAL DEFAULT 7 glDisableVertexAttribArra

which tells you that there are 3 functions defined in /usr/lib/tls/ which start with glDisable*

Thank you very much for your answer! I did as you told me, and I got: => (0xffffe000) => /lib/tls/ (0xb7083000) => /usr/X11R6/lib/ (0xb704c000) => /usr/lib/ (0xb702c000)
/lib/ (0x80000000) => /usr/X11R6/lib/ (0xb7023000) => /usr/X11R6/lib/ (0xb700b000) => /usr/X11R6/lib/ (0xb6ff5000) => /usr/X11R6/lib/ (0xb6fe6000) => /usr/X11R6/lib/ (0xb6fde000) => /usr/X11R6/lib/ (0xb6f12000) => /usr/X11R6/lib/ (0xb6ec1000) => /lib/ (0xb6ebd000)

I think that where ther’s not => it means I don’t have that library?

Then I also typed

readelf -s /usr/X11R6/lib/ | grep glDisable

And I got nothing! Nothing appeared on the console!
Is it normal?

[paolo@paolo ~]$ readelf -s /usr/X11R6/lib/ | grep glDisable
[paolo@paolo ~]$

that’s ok, because glDisable should be in libGL, not in libglut. if you type the readelf command without grep, you’ll see all functions and symbols defined in the lib.

it seems that your executable is not linked with libGL or libGLU at all. that seems a bit strange to me. how do you compile? i think it should look like

gcc -o glut -lX11 -lGL -lGLU -lglut

Wel, there aren’t those flgs, but I got this project from someone else, and I worked withou those. Anyway if I add them I get an error, saying it can’t find -lGLU…

It’s somewhat strange that the linker complained about nothing…

Yes, I think it’s really strange…
Anyway I get this error:

symbol lookup error: /usr/local/DGL2KSmartServer/lib/ undefined symbol: glDisable is a library that i load at runtime with dlsym…

Any other ideas?
Thank you for your help!

still strange. you need libGL to run a glut program, so you have to set the according compiler flag.

“can’t find lGLU” could mean that libGLU is not installed, or that the compiler just doesn’t find it.

to check if the libs are installed, you could just search in the default library paths (/usr/lib, /usr/X11R6/lib etc.), or if you have a prog installed that uses opengl, run ldd on that program.

if the libs are present somewhere, you can

a) copy them to the default library directory where the other libs are and run ldconfig afterwards


b) set the compiler flag -L to tell gcc where to look for the lib:

gcc -L/home/paolo/locallib -o glut -lX11 -lGL -lGLU -lglut

Now it seems it compiles with the -lGLU flag, but when I run the program it says again that it can’t find the library… It’s a very strange problem IMHO, since when I compile and link there isn’t any error message, only when I run…

I just tried eith ldd with the -r option and I got this: =>  (0xffffe000) => /lib/tls/ (0xb7038000) => /usr/X11R6/lib/ (0xb7001000) => /usr/lib/ (0xb6fe1000)
    /lib/ (0x80000000) => /usr/X11R6/lib/ (0xb6fd8000) => /usr/X11R6/lib/ (0xb6fc0000) => /usr/X11R6/lib/ (0xb6fa9000) => /usr/X11R6/lib/ (0xb6f9b000) => /usr/X11R6/lib/ (0xb6f93000) => /usr/X11R6/lib/ (0xb6ec7000) => /usr/X11R6/lib/ (0xb6e76000) => /lib/ (0xb6e71000)

undefined symbol: glPixelStorei (/usr/X11R6/lib/
undefined symbol: glBitmap (/usr/X11R6/lib/
undefined symbol: gluErrorString (/usr/X11R6/lib/
undefined symbol: glPopAttrib (/usr/X11R6/lib/
undefined symbol: glMapGrid2f (/usr/X11R6/lib/
undefined symbol: glRotatef (/usr/X11R6/lib/
undefined symbol: glEvalMesh2 (/usr/X11R6/lib/
undefined symbol: glFinish (/usr/X11R6/lib/
undefined symbol: glVertex3f (/usr/X11R6/lib/
undefined symbol: glXQueryExtension (/usr/X11R6/lib/
undefined symbol: glNormal3fv (/usr/X11R6/lib/
undefined symbol: gluNewQuadric (/usr/X11R6/lib/
undefined symbol: glViewport (/usr/X11R6/lib/
undefined symbol: glVertex3fv (/usr/X11R6/lib/
undefined symbol: glBegin (/usr/X11R6/lib/
undefined symbol: cosf (/usr/X11R6/lib/
undefined symbol: glDrawBuffer (/usr/X11R6/lib/
undefined symbol: glXMakeCurrent (/usr/X11R6/lib/
undefined symbol: gluQuadricDrawStyle (/usr/X11R6/lib/
undefined symbol: glXQueryExtensionsString (/usr/X11R6/lib/
undefined symbol: glVertex2f (/usr/X11R6/lib/
undefined symbol: glXChooseVisual (/usr/X11R6/lib/
undefined symbol: gluCylinder (/usr/X11R6/lib/
undefined symbol: glGetError (/usr/X11R6/lib/
undefined symbol: glGetIntegerv (/usr/X11R6/lib/
undefined symbol: glPushAttrib (/usr/X11R6/lib/
undefined symbol: glXDestroyContext (/usr/X11R6/lib/
undefined symbol: glPopMatrix (/usr/X11R6/lib/
undefined symbol: glXWaitX (/usr/X11R6/lib/
undefined symbol: glXGetProcAddressARB (/usr/X11R6/lib/
undefined symbol: glXQueryVersion (/usr/X11R6/lib/
undefined symbol: glGetString (/usr/X11R6/lib/
undefined symbol: gluQuadricNormals (/usr/X11R6/lib/
undefined symbol: glXGetClientString (/usr/X11R6/lib/
undefined symbol: glPushMatrix (/usr/X11R6/lib/
undefined symbol: glEnable (/usr/X11R6/lib/
undefined symbol: glNormal3f (/usr/X11R6/lib/
undefined symbol: sinf (/usr/X11R6/lib/
undefined symbol: gluSphere (/usr/X11R6/lib/
undefined symbol: glPolygonMode (/usr/X11R6/lib/
undefined symbol: glMap2f (/usr/X11R6/lib/
undefined symbol: glScalef (/usr/X11R6/lib/
undefined symbol: glReadBuffer (/usr/X11R6/lib/
undefined symbol: glXIsDirect (/usr/X11R6/lib/
undefined symbol: glXSwapBuffers (/usr/X11R6/lib/
undefined symbol: glTranslatef (/usr/X11R6/lib/
undefined symbol: glXCreateContext (/usr/X11R6/lib/
undefined symbol: glXGetConfig (/usr/X11R6/lib/
undefined symbol: glEnd (/usr/X11R6/lib/
undefined symbol: glPixelStorei (./
undefined symbol: pthread_create (./
undefined symbol: glDrawPixels (./
undefined symbol: glFlush (./
undefined symbol: glRasterPos2d (./
undefined symbol: glDisable (./
undefined symbol: pthread_detach (./
undefined symbol: glViewport (./
undefined symbol: glPixelZoom (./
undefined symbol: glRasterPos2i (./
undefined symbol: glPixelTransferi (./
undefined symbol: glGetString (./

Any idea on what does it mean? Why there are so much undefined symbol?

the gl* and glX* functions are in libGL, the glu* functions in libGLU.

sinf and cosf are missing, too. they are in the math lib, libm. pthread_detach should be in libpthread.

can you show me the complete command line that you use for compilation?

I use this:

@$(CC) remote_desktop.c remote_desktop_win.c remote_desktop_rect.c remote_desktop_decode.c remote_desktop_info_box.c util.c util_layer3.c settings.c -fPIC -c
@$(CC) remote_desktop.o remote_desktop_win.o remote_desktop_rect.o remote_desktop_decode.o remote_desktop_info_box.o util.o -o -lc -lglut -ljpeg -Wl,-soname, -shared $(CFLAGS)

Where CC is Gcc and cflag is only a flag for optimization…

This morning I deleted every gl* and GL* library I had and reinstalled all. Everything worked fine. But then I unistalled my program and installled again and I get that damn error again. I show you the install script too:

@install smartserver $(INSTALL_DIR)
@rm -f /usr/bin/smartserver*
@ln -s $(INSTALL_DIR)/smartserver_udp 
@ln -s $(INSTALL_DIR)/smartserver /usr/bin/smartserver

@install $(INSTALL_DIR)/lib