OpenGL, glfw, and X11 init


I’m trying to create a snap of an open-source image-viewer project of mine at
using snapcraft version 4.1.1 with a core 20 VM. The yaml file can be seen here:

The app uses an OpenGL-based immediate-mode GUI toolkit (Dear IMGUI). It links statically (yes, I know) with glfw and uses the cmake build generator.

After the snap is ‘crafted’ and installed, if I run by typing tacentview in a terminal, I am greeted with

Glfw Error 65544: X11: Failed to load Xlib.

If I directly run the installed snap app (not using the symbolic link in /snap/bin) by typing /snap/tacentview/current/tacentview, Glfw successfully initializes. I don’t get any env vars that way (the app needs SNAP_USER_DATA and SNAP_USER_COMMON), but sure enough if I temporariliy manually set them, it all works, I get my glfw X11 window etc.

The specific glfw line that fails in x11_init.c is:

_glfw.x11.xlib.handle = _glfw_dlopen(“”);

In short, running /snap/tacentview/current/tacentview works, but running /snap/bin/tacentview (which symbolically links to /usr/bin/snap) does not.

The fact the running from one location works at all leads me to believe I have setup the plugs/dependencies/whatnot correctly in the yaml file – or have I ?

make use of the desktop-launch script that you added with the glib-only part … i.e.:

command: desktop-launch tacentview

in your snapcraft.yaml …

that launcher sets a bunch of variables

along with that, there is

snap run --strace tacentview

that should give you some info about the search paths your app walks …

Hi ogra, thanks for the pointers.

I keep getting:

Failed to generate snap metadata: The specified command ‘desktop-launch tacentview’ defined in the app ‘tacentview’ is not executable.

Looking at desktop-launch in the VM under prime/bin I do see it has ugo+x perms. I’ll push forward with getting the script to run in any case.

Edit: Sorry for the necrobump, somehow this thread ended up in my open tabs and I’d missed the dates on the posts. Since this is a valid answer I’ll keep it visible, but sorry if this ends up as a notification/email

Core 20 requires the command to be relative from prime/$SNAP, core18 was more lenient here and so examples that work with core18 might work where core20 doesn’t.

command: bin/desktop-launch $SNAP/bin/tacentview

1 Like

Can’t quite remember how I got it going on core20, but I do seem to remember it had something to do with relative paths. Thanks James.