PDA

View Full Version : Building GL apps [FreeBSD 4.8]


driehuis
04-14-03, 06:46 PM
The shared libraries installed by the nvidia driver kit do not contain symbols (they are stripped). That results in link errors when building apps that require libGL.so.

I could work around it by linking to the /usr/X11R6/lib/XXX-libGL.so.1.%%.XFree86-libraries-4.3.0_1 shared library, but that ranks as one of the worst hacks I've had to do lately.

I feel I'm overlooking something obvious.

Here's the history for folks who may be in the know:

When upgrading from FreeBSD 4.7 to 4.8, the upgrade barfed on XFree86. I manually removed everything dealing with X with pkg_delete, and installed the 4.8 packages in this order:
- XFree86-4.3.0
- Mesa
- nvidia-driver (from /usr/ports)

Precompiled apps work fine, but recompiling them won't:

% make
gcc -pthread -g -O2 -pipe -L/usr/local/lib -L/usr/X11R6/lib -o gl-info gl-info.o -lglut -lGLU -lGL -lXmu -lXt -lSM -lICE -lXi -lXext -lX11 -lm -lm
/usr/X11R6/lib/libglut.so: undefined reference to `glXBindChannelToWindowSGIX'
/usr/X11R6/lib/libglut.so: undefined reference to `glXQueryChannelDeltasSGIX'
/usr/X11R6/lib/libglut.so: undefined reference to `glXChannelRectSyncSGIX'
/usr/X11R6/lib/libglut.so: undefined reference to `glXChannelRectSGIX'
/usr/X11R6/lib/libglut.so: undefined reference to `glXQueryChannelRectSGIX'

Seeing that the nvidia drivers moved the libGL.so that came with XFree out if the way, and replacing them with a stripped library, I can understand the behavior. But it did this as well on FreeBSD 4.7, so I'm at a complete loss as to what is different.

I copied the original XFree86 libGL.so to a directory earlier in the (-L) link timepath but later in the (ldconfig) runtime path, which works but is jucky at best...

bwkaz
04-14-03, 09:42 PM
The problem isn't that libGL is stripped. If it was stripped, then it wouldn't work at all -- you'd be getting a LOT more undefined references, like to every single GL* function. Unless you mean that the debug data is stripped out of them? That affects linking in exactly zero ways.

There is another thread going, about problems with various glut implementations that do not properly query extensions (they just assume the SGI extensions will be there, when they in fact are not -- what they should do is use glXGetProcAddressARB() or whatever the function is, and bind at runtime), and just assume these SGI extensions exist.

The RedHat default libglut does the exact same thing. The fix is to recompile Mesa's glut -- search for your missing symbols to find the thread. I've explained in there how to do it (for Linux, but it should work with BSD as well). You'll then have to remove the X11R6 glut library.

driehuis
04-15-03, 05:30 PM
Yeah, you're right, of course. I forgot that FreeBSD's .so's are a bit different from BSDi's ;-)

Thanks for taking the time to point out the errors of my ways, and for the pointer.