PDA

View Full Version : opengl compilation on linux - not working ??



08-15-2002, 09:14 PM
hi there, hope you guys can help me cause im at my wits end.

im running rh 7.3 and i have installed the Nvidia 1.0.2960 kernel and glx modules. i have also installed the glut libraries as well. i have checked the symlinks between the libs for gl, glu, glut and x11. my problem is that i cant compile anything at all involving any of these libraries. here is the output from the makefile for lesson01linux from Nehe's site.

[drew@Bg3ntl lesson01linux]$ make lesson1
gcc -Wall -I/usr/include/ -c -o lesson1.o lesson1.c
lesson1.c: In function `keyPressed':
lesson1.c:75: warning: implicit declaration of function `exit'
gcc -Wall -I/usr/include/ -o lesson1 -L/usr/X11R6/lib lesson1.o -lX11 -lXi -lXmu -lglut -lGL -lGLU -lm
/usr/X11R6/lib/libGL.a(glxext.o): In function `__glXGetCurrentContext':
glxext.o(.text+0x1a): undefined reference to `pthread_key_create'
glxext.o(.text+0x31): undefined reference to `pthread_getspecific'
/usr/X11R6/lib/libGL.a(glxext.o): In function `__glXSetCurrentContext':
glxext.o(.text+0x6a): undefined reference to `pthread_key_create'
glxext.o(.text+0x87): undefined reference to `pthread_setspecific'
/usr/X11R6/lib/libGL.a(glthread.o): In function `_glthread_InitTSD':
glthread.o(.text+0x1e): undefined reference to `pthread_key_create'
/usr/X11R6/lib/libGL.a(glthread.o): In function `_glthread_GetTSD':
glthread.o(.text+0x76): undefined reference to `pthread_getspecific'
/usr/X11R6/lib/libGL.a(glthread.o): In function `_glthread_SetTSD':
glthread.o(.text+0xbf): undefined reference to `pthread_setspecific'
collect2: ld returned 1 exit status
make: *** [lesson1] Error 1

it looks like there is something wrong with my glx and/or gl libs. any help would be greatly appreciated - if i need to provide anymore details just tell me what i need to supply.

thanks, drew

OldMan
08-16-2002, 02:30 AM
Include in your compile line.. -lpthread

that is the multi thread library

08-16-2002, 04:10 PM
Adding the pthread library will certainly resolve the link issue; however, I believe you will find that you will not be able to obtain a direct rendering context within your programs.

I also had this same problem after installing the nVidia GLX RPM. Basically, you are linking with the wrong GL library and/or other related libraries. If you link with the correct libraries, you will not need the pthread library addition to your makefile.

I was able to resolve this problem by downloading the GLX source (SRC) RPM and running the included makefile. This makefile installs the nVidia libraries and removes existing libraries that might conflict. For some reason, this cleanup/removal does not occur when installing the binary RPM.

Anyway, once you've finished the SRC RPM install by running the makefile, you should be able to compile without the pthreads library and you should also be able to get a direct rendering context.

The direct rendering context issue is what originally tipped me off that I had a problem. My programs compiled and ran by adding the pthreads library (among other things), but I could not sync to VBLANK and so forth. glXIsDirect() would always return false even though glxinfo indicated that direct rendering was supported. Once I corrected the problem via installation from the GLX source RPM, I was able to get direct rendering contexts and perform VBLANK synchronization, etc.

Hope this helps you and others resolve this problem quickly instead of having to dink around with the problem for several days trying to figure out what is going on. Would have been easier to diagnose if the programs simply would not link and run! http://www.opengl.org/discussion_boards/ubb/smile.gif

Later!

08-18-2002, 07:08 PM
Thnx for the help. Well i tried installing the GLX source RPM but there was no makefile so i ran the rpm --rebuild etc and installed it but the same problem cropped up again. i linked with the lpthread library and it compiled http://www.opengl.org/discussion_boards/ubb/smile.gif But now my problem is i dont have permissions to run the program. I have tried chmod 777 <the file> but it always says to me 'permission denied' when i try and run it, no matter if im the superuser or not.

also, as a side note, the matrix screensaver in kde runs *very* slowly ever since in installed the nvidia drivers. does this point to a problem again ?

08-19-2002, 09:29 AM
Hmmm, I'm not personally familiar with exactly what --rebuild does... I used the RedHat Package manager GUI to install the SRC RPM and then manually ran the makefile.

When you install a source RPM, the source contents are unpacked into:

/usr/src/redhat/SOURCES/

In the case of nVidia's GLX SRC RPM the full path ends up being:

/usr/src/redhat/SOURCES/NVIDIA_GLX-1.0-2960

However, you may no longer have this directory since you installed with the --rebuild option. From what I understand about this option in the man pages, it sounds like it may remove the sources after "installation." Try installing it without the --rebuild and then see if you have this source directory. Once you've got this directory, log in as root, cd to this directory, and run make.

This is what worked for me. I'm not sure why the method you used did not seem to work; however, I do know that when you install the binary RPM package, rpm also fails to successfully remove these files. Thus, I'd suggest giving it a try manually.

I've downloaded, compiled, and run a number of the NeHe demos without having to modify their makefile (no -lpthreads needed). The only time I saw this behavior was prior to getting the GL/GLX libraries properly installed without conflicting libraries.
Sounds like you still have some conflicting libraries hanging around.

08-19-2002, 03:17 PM
My guess is that the wrong libraries is in the /usr/X11R6/lib/ directory so at least on RH does everything works if you do not have to build with -L/usr/X11R6/lib. A tricky one. http://www.opengl.org/discussion_boards/ubb/smile.gif
Here is some of the cleanup calls from the makefile
rm -f /usr/X11R6/lib/libGL.*
rm -f /usr/X11R6/lib/libGLcore.*
rm -f /usr/X11R6/lib/modules/extensions/libGLcore.*
rm -f /usr/X11R6/lib/modules/extensions/libglx.*

For the permission denied can you try
chmod 0666 /dev/nvidia* chown root /dev/nvidia*