OpenGL error: MESA-LOADER fails

Hi,
I’m trying to snap my game. I can install the *.snap file I get after running $ snapcraft, but when I try to run it I get this output:

caleb@whistling-duck:~/projects/gladupe$ gladupe
gladupe 0.1 installed
libGL error: MESA-LOADER: failed to open i965 (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)
libGL error: failed to load driver: i965
libGL error: MESA-LOADER: failed to open i965 (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)
libGL error: failed to load driver: i965
libGL error: MESA-LOADER: failed to open swrast (search paths /usr/lib/x86_64-linux-gnu/dri:\$${ORIGIN}/dri:/usr/lib/dri)
libGL error: failed to load driver: swrast
X Error:  GLXBadContext
  Request Major code 152 (GLX)
  Request Minor code 6 ()
  Error Serial #112
  Current Serial #111

After a few searches I found this: Adding OpenGL/GPU support to a snap
But after changing my snapcraft.yaml as the link says, the error was the same.
The only OpenGL-related stuff I had in there before was libgl1 and libglx0 in stage-packages.
While my project doesn’t directly need OpenGL, for snapcraft I’m statically compiling with my game two libraries that do.
That being said, how do I solve or avoid this error?
Thanks.

Edit: I thought I’d note that when I install it, I can do

caleb@whistling-duck:~$ cd /snap/gladupe/current
caleb@whistling-duck:/snap/gladupe/current$ bin/gladupe 

and it works fine.

I was playing around a bit snapping a “game” I wrote (C++ SDL2 using OpenGL/Egles and mir-kiosk for wayland display server on RPI with Ubuntu Core). I found I needed an environment including this to endable SDL to find the shared object files:

environment:
  LD_LIBRARY_PATH: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/dri:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/mesa:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/mesa-gl:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/xorg:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio/
  LIBGL_DRIVERS_PATH: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/dri `

Perhaps my snapcraft.yaml will help out: https://github.com/knitzsche/ripples/blob/master/snapcraft.yaml#L14

3 Likes

The desktop-helpers usually care for this, so you do not need to separately set the env. they work excellent in kiosk setups on core too (and care for a lot of other stuff, like proper font configs and keyboard setup in your environment) :wink:

Alright thanks, I’ll look into that.

I had to also use the environment that kyleN posted for my snap. Couldn’t get it to work any other way. (I am using helpers in Adding OpenGL/GPU support to a snap too).

1 Like