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

    libGL.so.1 => /usr/lib/tls/libGL.so.1 (0x40024000)
    libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x4008d000)
    libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x4009b000)
    libpthread.so.0 => /lib/tls/libpthread.so.0 (0x4017a000)
    libm.so.6 => /lib/tls/libm.so.6 (0x40187000)
    libc.so.6 => /lib/tls/libc.so.6 (0x42000000)
    libGLcore.so.1 => /usr/lib/tls/libGLcore.so.1 (0x401aa000)
    libdl.so.2 => /lib/libdl.so.2 (0x40662000)
    /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (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/libGL.so.1 | 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/libGL.so.1 which start with glDisable*

Thank you very much for your answer! I did as you told me, and I got:

linux-gate.so.1 => (0xffffe000)
libc.so.6 => /lib/tls/libc.so.6 (0xb7083000)
libglut.so.3 => /usr/X11R6/lib/libglut.so.3 (0xb704c000)
libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0xb702c000)
/lib/ld-linux.so.2 (0x80000000)
libSM.so.6 => /usr/X11R6/lib/libSM.so.6 (0xb7023000)
libICE.so.6 => /usr/X11R6/lib/libICE.so.6 (0xb700b000)
libXmu.so.6 => /usr/X11R6/lib/libXmu.so.6 (0xb6ff5000)
libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0xb6fe6000)
libXi.so.6 => /usr/X11R6/lib/libXi.so.6 (0xb6fde000)
libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0xb6f12000)
libXt.so.6 => /usr/X11R6/lib/libXt.so.6 (0xb6ec1000)
libdl.so.2 => /lib/libdl.so.2 (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/libglut.so.3 | grep glDisable

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

[paolo@paolo ~]$ readelf -s /usr/X11R6/lib/libglut.so.3 | 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 glut.cc -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/remote_desktop.so: undefined symbol: glDisable

remote_desktop.so 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

or

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

gcc -L/home/paolo/locallib -o glut glut.cc -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:

    linux-gate.so.1 =>  (0xffffe000)
    libc.so.6 => /lib/tls/libc.so.6 (0xb7038000)
    libglut.so.3 => /usr/X11R6/lib/libglut.so.3 (0xb7001000)
    libjpeg.so.62 => /usr/lib/libjpeg.so.62 (0xb6fe1000)
    /lib/ld-linux.so.2 (0x80000000)
    libSM.so.6 => /usr/X11R6/lib/libSM.so.6 (0xb6fd8000)
    libICE.so.6 => /usr/X11R6/lib/libICE.so.6 (0xb6fc0000)
    libXmu.so.6 => /usr/X11R6/lib/libXmu.so.6 (0xb6fa9000)
    libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0xb6f9b000)
    libXi.so.6 => /usr/X11R6/lib/libXi.so.6 (0xb6f93000)
    libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0xb6ec7000)
    libXt.so.6 => /usr/X11R6/lib/libXt.so.6 (0xb6e76000)
    libdl.so.2 => /lib/libdl.so.2 (0xb6e71000)

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

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 remote_desktop.so -lc -lglut -ljpeg -Wl,-soname,remote_desktop.so -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_remote_desktop:
@install remote_desktop.so $(INSTALL_DIR)/lib