Failing to load Mesa3D on macOS instead of macOS provided OpenGL library

Thanks again for your suggestions. I was able to build but the program fails at execution with an error I can not resolve.

martin@osxm1 ~/D/j/e/mesa-demos > DISPLAY=:0 ./build/glxinfo -B

name of display: :0
X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  149 ()
  Minor opcode of failed request:  34
  Serial number of failed request:  7
  Current serial number in output stream:  7

I found ways to clarify these error codes here:

  • running xdpyinfo -queryExt | grep opcode returns that the error involves the GLX extension (... GLX (opcode: 149, base event: 102, base error: 161) ...)
  • then minor opcode 34 seams to be provided here and meaning GLX:CreateContextAttribsARB.
  • the serial number of failed request 7 lead to R007 GLX:QueryVersion

For information I slightly modified the build command you suggested as follow

mkdir build/

# export path_to_mesa:path_to_macport_libraries:path_to_XQuartz
export C_INCLUDE_PATH=/Users/Martin/Dev/jzy3d/external/osmesa/include:/opt/local/include/:/opt/X11/include
export CPLUS_INCLUDE_PATH=/Users/Martin/Dev/jzy3d/external/osmesa/include:/opt/local/include/:/opt/X11/include
export LIBRARY_PATH=/Users/Martin/Dev/jzy3d/external/osmesa/lib:/opt/local/lib/:/opt/X11/lib

gcc -lgl -lX11 src/xdemos/glinfo_common.c src/xdemos/glxinfo.c -o build/glxinfo

The same problem occured when using path /opt/X11/lib (macports) and removing /opt/local/lib/ (macports).

One thing I noticed is that XQuartz has a libGL.dylib in /opt/X11/lib/