OpenGL, glfw, and X11 init

Hi,

I’m trying to create a snap of an open-source image-viewer project of mine at https://github.com/bluescan/tacentview
using snapcraft version 4.1.1 with a core 20 VM. The yaml file can be seen here:
https://github.com/bluescan/tacentview/blob/master/Linux/snapcraft/snap/snapcraft.yaml

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(“libX11.so.6”);

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.