[patch] Use dlsym instead of glXGetProcAddress in xdriinfo

Ian Romanick idr at us.ibm.com
Wed Nov 23 07:27:14 PST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Matthias Hopf wrote:
> On Nov 21, 05 18:08:48 -0500, Felix Kühling wrote:
> 
>>The attached patches (monolithic and modular) should fix dynamic linking
>>problems with xdriinfo, that NVidia users were complaining about. Their
>>libGL doesn't define glXGetProcAddress but only glXGetProcAddressARB.
>>The cleanest solution that works with any libGL is to use dlopen and
>>dlsym instead. This has the nice side effect that it removes all
>>build-time dependencies on libGL and GLX headers. There is only one
>>catch: does Xorg currently support any architectures that don't have
>>dlopen/dlsym in dlfcn.h?
> 
> I don't think using dlym is actually allowed, as the OpenGL calls are
> not neccessarily expected to be exported (and can even be context
> dependend).

No, no, no!!!  On GLX, function pointers are explicitly defined to be
context independent.  The same is not true on WGL.  However, the pointer
returned by glXGetProcAddress for statically exported functions need not
be the same as the statically exported address (which is what dlsym
would return).  So 'glXGetProcAddressARB("glVertex3fv")' may not return
the address of the static glVertex3fv function.

In general, you are correct that dlsym should not be used for this sort
of thing.  This particular usage falls outside the range of "in
general".  Using dlsym to get the address of an explicitly
platform-dependent symbol is different than an application trying to
access a platform-independent API entrypoint.

> However, a valid solution used by most games is to dynamically load
> libGL, and use dlsyn to get either glXGetProcAddress or
> glXGetProcAddressARB, whatever is defined.

The Linux OpenGL ABI *requires* that glXGetProcAddressARB be statically
exported by libGL (see section 3.6).

http://oss.sgi.com/projects/ogl-sample/ABI/index.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFDhIpRX1gOwKyEAw8RAuIfAKCJX9cKXT5QUgZ9MYu/CvMz/3r8qACeKZYa
WxFx1xxNo8Nezk8QTcK5XKA=
=RcI7
-----END PGP SIGNATURE-----



More information about the xorg mailing list