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

**URL:** <https://community.khronos.org/t/failing-to-load-mesa3d-on-macos-instead-of-macos-provided-opengl-library/108408>\
**Category:** OpenGL\
**Created:** [March 15, 2022, 4:04pm UTC](https://community.khronos.org/t/failing-to-load-mesa3d-on-macos-instead-of-macos-provided-opengl-library/108408 "2022-03-15T16:04:36Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![Martin3d](https://community.khronos.org/user_avatar/community.khronos.org/martin3d/32/7503_2.png) [@Martin3d](https://community.khronos.org/u/Martin3d)\
**Post date:** [March 25, 2022, 3:39pm UTC](https://community.khronos.org/t/failing-to-load-mesa3d-on-macos-instead-of-macos-provided-opengl-library/108408/17 "2022-03-25T15:39:12Z")

</div>

Thanks @Atemu.

Unfortunately the `__GLX_VENDOR_LIBRARY_NAME=mesa` does not change anything.

I ran otool on `glxgears` to check its dependencies and found that the GL libraries are those installed in MacPorts directory so I assume it is Mesa’s GL being used as imported from MacPorts (otherwise one would see a more conventional MacOS path like `/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib`). I have no real proof that this libGL is Mesa’s one though.

```auto
martin@osxm1 ~/D/j/e/mesa-demos (main)> otool -L /opt/local/bin/glxgears
/opt/local/bin/glxgears:
	/opt/local/lib/libGL.1.dylib (compatibility version 4.0.0, current version 4.0.0)
	/opt/local/lib/libX11.6.dylib (compatibility version 11.0.0, current version 11.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)

```

And also

```auto
martin@osxm1 ~/D/j/e/mesa-demos (main) [1]> otool -L /opt/local/bin/glxinfo
/opt/local/bin/glxinfo:
	/opt/local/lib/libGL.1.dylib (compatibility version 4.0.0, current version 4.0.0)
	/opt/local/lib/libX11.6.dylib (compatibility version 11.0.0, current version 11.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)

```

I then verified `libGL`

```auto
martin@osxm1 ~/D/j/e/mesa-demos (main)> otool -L /opt/local/lib/libGL.1.dylib
/opt/local/lib/libGL.1.dylib:
	/opt/local/lib/libGL.1.dylib (compatibility version 4.0.0, current version 4.0.0)
	/opt/local/lib/libexpat.1.dylib (compatibility version 8.0.0, current version 8.12.0)
	/usr/lib/libXplugin.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	/opt/local/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
	/opt/local/lib/libglapi.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/opt/local/lib/libXext.6.dylib (compatibility version 11.0.0, current version 11.0.0)
	/opt/local/lib/libXdamage.1.dylib (compatibility version 3.0.0, current version 3.0.0)
	/opt/local/lib/libXfixes.3.dylib (compatibility version 5.0.0, current version 5.0.0)
	/opt/local/lib/libX11-xcb.1.dylib (compatibility version 2.0.0, current version 2.0.0)
	/opt/local/lib/libX11.6.dylib (compatibility version 11.0.0, current version 11.0.0)
	/opt/local/lib/libxcb.1.dylib (compatibility version 3.0.0, current version 3.0.0)
	/opt/local/lib/libxcb-glx.0.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.0.0)
	/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 54.0.0)
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1770.106.0)
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 904.4.0)

```

Yet, we don’t know if the imported libGL was built with the `-Dglx=xlib` so it is worth trying to build a `glxgear`/`glxinfo` linking to the previous Mesa build that I succeeded to run (which was made with `meson builddir/ -Dosmesa=true -Dglx=xlib -Dgallium-drivers=swrast -Ddri-drivers=[] -Dvulkan-drivers=[] -Dprefix=/Users/Martin/Dev/jzy3d/external/osmesa`).

**Where did you get glxinfo from?** I unfortunately can’t build [Mesa’s demo found here](https://gitlab.freedesktop.org/mesa/demos) successfully.

_configure fails as follow_

```auto
martin@osxm1 ~/D/j/e/mesa-demos (main)> ./configure.ac
./configure.ac: line 25: dnl: command not found
./configure.ac: line 27: syntax error near unexpected token `[2.59]'

```

_cmake fails as follow_

```auto
martin@osxm1 ~/D/j/e/mesa-demos-build (master)> make
[0%] Building C object src/glad/CMakeFiles/glad.dir/src/glad.c.o
[0%] Linking C static library libglad.a
[0%] Built target glad
[0%] Building C object src/util/CMakeFiles/util.dir/readtex.c.o
[0%] Building C object src/util/CMakeFiles/util.dir/shaderutil.c.o
/Users/martin/Dev/jzy3d/external/mesa-demos/src/util/shaderutil.c:45:13: error: variable has incomplete type 'void'
static void GLAPIENTRY
            ^
/Users/martin/Dev/jzy3d/external/mesa-demos/src/glad/include/glad/glad.h:895:20: note: expanded from macro 'GLAPIENTRY'
#define GLAPIENTRY APIENTRY
                   ^
/Users/martin/Dev/jzy3d/external/mesa-demos/src/util/shaderutil.c:45:23: error: expected ';' after top level declarator
static void GLAPIENTRY
                      ^
                      ;
2 errors generated.
make[2]: *** [src/util/CMakeFiles/util.dir/shaderutil.c.o] Error 1
make[1]: *** [src/util/CMakeFiles/util.dir/all] Error 2
make: *** [all] Error 2

```

One funny thing though is that enabling `LIBGL_ALWAYS_SOFTWARE` - which I though was a Mesa only environment variable lead to Apple Software rendering activation.

```auto
export LIBGL_ALWAYS_SOFTWARE=true
martin@osxm1 ~/D/j/external (master)> glxinfo | head -n 50
...
OpenGL vendor string: Apple Inc.
OpenGL renderer string: Apple Software Renderer
OpenGL version string: 2.1 APPLE-18.5.9
OpenGL shading language version string: 1.20

export LIBGL_ALWAYS_SOFTWARE=false
martin@osxm1 ~/D/j/external (master)> glxinfo | head -n 50
...
OpenGL vendor string: Apple
OpenGL renderer string: Apple M1
OpenGL version string: 2.1 Metal - 71.6.4
OpenGL shading language version string: 1.20

```

---

_[View the full topic](https://community.khronos.org/t/failing-to-load-mesa3d-on-macos-instead-of-macos-provided-opengl-library/108408)._
