November 5, 2005 5:36 PM
I had trouble linking to the Irrlicht library. It always complained that linking to glXGetProcAddress() failed. As always, google didn't fail me and I found out the cause of the problem. Typically, GLX implementation of the NVIDIA driver does not have glXGetProcAddress. The patch for this in Irrlicht is simple, you have to modify COpenGLDriver.cpp by adding the following line after
#define glXGetProcAddress glXGetProcAddressARB
Once you do this, compile Irrlicht.
What this means to developers using OpenGL
To recap, linking issues with glXGetProcAddress() probably mean
an Nvidia driver is installed in Linux. Just change all
glXGetProcAddress() calls using the above
glXGetProcAddressARB() calls. This fix only works for me if the
define is placed before including glx.h.
So how do you handle this portably? Obviously, there are people out there with Nvidia drivers installed and there are others with a perfectly working glXGetProcAddress. This is where autoconf comes to one's rescue. If you're not familiar with autoconf/automake, then this would be the time to get familiar with it.
This simple autoconf test will check exactly for such a situation and
defines a special variable in case it is encountered when the user runs
#after checking for opengl have_glx=no AC_CHECK_HEADER([GL/glx.h], have_glx=yes, AC_MSG_ERROR([Required file glx.h missing!])) if test "$have_glx" = yes; then have_procaddr=no AC_CHECK_FUNCS([glXGetProcAddress], have_procaddr=yes, AC_MSG_WARN([glXGetProcAddress is not linkable. Enabling fix for such a situation...])) if test "$have_procaddr" = no; then AC_CHECK_FUNCS([glXGetProcAddressARB],AC_DEFINE(HAVE_GLX_BUT_NO_GLXGETPROCADDR), AC_MSG_ERROR([You don't have glXGetProcAddressARB as well. Bailing!])) fi fi
Once you put this in configure.in, and include config.h (generated by autoheader), the following code in your C or C++ source file will automatically enable this fix.
/* add config.h */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #ifdef HAVE_GLX_BUT_NO_GLXGETPROCADDR /* This has to come before glx.h is included. */ #define glXGetProcAddress glXGetProcAddressARB #endif #include <GL/glx.h> #endif