Cannot find library even when included in the staging packages

Pastebin

I am getting the error

/snap/rolisteam/x1/usr/local/bin/rolisteam: error while loading shared libraries: libpulsecommon-11.1.so: cannot open shared object file: No such file or directory

but have included libpulse0 in with the staging packages.

My snapcraft.yaml

name: rolisteam
version: "1.9.0"
summary: RPG Tabletop Manager
description: |
  Rolisteam is a virtual tabletop software. It helps you to manage 
  tabletop role playing games with remote friends/players. 
  It provides many features to share maps, pictures and it also 
  includes tool to communicate with your friends/players. 
  The goal is to make Rolisteam-managed RPG games as good as 
  RPG games around your table. 
  To achieve it, we are working hard to provide you more and more features. 


confinement: strict
base: core18

parts:
  rolisteam:
    plugin: qmake
    source-type: git
    source: https://github.com/Rolisteam/rolisteam.git
    build-packages:
      - qt5-default
      - qtbase5-dev-tools
      - qt5-qmake 
      - libqt5network5
      - zlib1g-dev 
      - build-essential
      - ca-certificates
      - qtmultimedia5-dev
      - libqt5core5a
      - libqt5gui5
      - qttools5-dev-tools
      - qtdeclarative5-dev
      - qtwebengine5-dev
      - libqt5svg5-dev         
    stage-packages:
      - libqt5network5
      - zlib1g
      - libqt5multimedia5
      - libqt5multimedia5-plugins
      - libqt5multimediaquick-p5
      - libqt5multimediawidgets5
      - libqt5core5a
      - libqt5gui5
      - libqt5webengine5
      - libqt5webenginewidgets5
      - libqt5svg5
      - libqt5xml5
      - libpulse0

apps:
  rolisteam:
    command: usr/local/bin/rolisteam
    plugs: 
      - home
      - network
      - pulseaudio
      - desktop
      - desktop-legacy
      - wayland
      - x11

And there does not seem to be any errors while building:

Staging rolisteam 
Priming rolisteam 
The execstacks are going to be cleared for the following files:
- /root/rolisteam/prime/usr/lib/x86_64-linux-gnu/libQt5WebEngineCore.so.5.9.5
To disable this behavior set `build-attributes: [keep-execstack]` for the part.
'grade' property not specified: defaulting to 'stable'
Snapping 'rolisteam' \                                                                                                                                     
Snapped rolisteam_1.9.0_amd64.snap

So any idea why it cannot find the library ?

TIA

see this post:

1 Like

I can see that the library is included in the stage area, just as you say under /stage/usr/lib/x86_64-linux-gnu/pulseaudio my question is why is it not picked up automatically? Why do I have have to put in a work around when it should automatically be added to the LD path?

I am sure your fix will work, and thanks for that, but should it be necessary ?

it probably should not, but it currently is … only the well known paths (/lib, /usr/lib, /usr/local/lib … etc) are in LD_LIBRARY_PATH in snaps, subdirs need to be manually added atm … this is also true for mesa drivers and other libs that store their shared objects in subdirs.

That makes me consider how they are preparing the sandbox for the build then. For sure when you build applications normally you will build against the dev package but the built library will always be in the same place.

Just seems a bit of a hack to me.

one problem is that snaps allow you to cross-build for a different target arch … to make this work on a non-native host you can only unpack the stage-packages but not run their postinst scripts (which might call native binaries of the target arch) … typically the adding of the additional linker path is done by putting a ld.so.conf snippet in place and calling ldconfig from a postinst debhelper snippet … but ldconfig is specific to the target arch so you cant exec it easily (that would require bigger and more complicated hacks to the build system).

based on the above, the adding of the search paths to the env variables of your app (or alternatively simply moving the libs all into the known search paths during snap build) is the less evil hack in the end :wink:

also note that many snaps do not really use stage-packages but build all their dependencies from source, so you can also not just generalize the fact that “everything runs a postinst script. lets just make that work” since you would need to special case all teh different setups.

Yeah… well that as may be, but I did not have the same headache with flatpaks put it that way. But the problem now is I need to add more than 1 search path as it also needs

$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/qt5/plugins

So the build file is starting to look a little ridiculous.

And that is not to say I might need to add qt5/qml as well?

All in all not particularly well documented in the build guides is it ?

EDIT.

So this is not going well either.

Now I am getting this error:

This application failed to start because it could not find or load the Qt platform plugin "xcb" in "".

But it is searching the plugins dir now.

stat("/proc/32718/exe", {st_mode=S_IFREG|0755, st_size=8313144, ...}) = 0
lstat("/proc/32718/exe", {st_mode=S_IFLNK|0777, st_size=0, ...}) = 0
lstat("/proc", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
lstat("/proc/32718", {st_mode=S_IFDIR|0555, st_size=0, ...}) = 0
lstat("/proc/32718/exe", {st_mode=S_IFLNK|0777, st_size=0, ...}) = 0
readlink("/proc/32718/exe", "/snap/rolisteam/x1/usr/local/bin"..., 4095) = 42
lstat("/snap", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/snap/rolisteam", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/snap/rolisteam/x1", {st_mode=S_IFDIR|0755, st_size=128, ...}) = 0
lstat("/snap/rolisteam/x1/usr", {st_mode=S_IFDIR|0755, st_size=102, ...}) = 0
lstat("/snap/rolisteam/x1/usr/local", {st_mode=S_IFDIR|0755, st_size=26, ...}) = 0
lstat("/snap/rolisteam/x1/usr/local/bin", {st_mode=S_IFDIR|0755, st_size=50, ...}) = 0
lstat("/snap/rolisteam/x1/usr/local/bin/rolisteam", {st_mode=S_IFREG|0755, st_size=8313144, ...}) = 0
stat("/snap/rolisteam/x1/usr/local/bin/qt.conf", 0x7fff18db8090) = -1 ENOENT (No such file or directory)
stat("/snap/rolisteam/x1/usr/local/bin/qt.conf", 0x7fff18db7d10) = -1 ENOENT (No such file or directory)
stat("/usr/lib/x86_64-linux-gnu/qt5/plugins", 0x7fff18db7e90) = -1 ENOENT (No such file or directory)
lstat("/snap", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/snap/rolisteam", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/snap/rolisteam/x1", {st_mode=S_IFDIR|0755, st_size=128, ...}) = 0
lstat("/snap/rolisteam/x1/usr", {st_mode=S_IFDIR|0755, st_size=102, ...}) = 0
lstat("/snap/rolisteam/x1/usr/local", {st_mode=S_IFDIR|0755, st_size=26, ...}) = 0
lstat("/snap/rolisteam/x1/usr/local/bin", {st_mode=S_IFDIR|0755, st_size=50, ...}) = 0
stat("/snap/rolisteam/x1/usr/local/bin", {st_mode=S_IFDIR|0755, st_size=50, ...}) = 0
stat("/snap/rolisteam/x1/usr/local/bin/platforms/.", 0x7fff18db7ec0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/qt5/qtlogging.ini", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
stat("/root/snap/rolisteam/x1/.config/QtProject/qtlogging.ini", 0x7fff18db7ef0) = -1 ENOENT (No such file or directory)
stat("/etc/xdg/QtProject/qtlogging.ini", 0x7fff18db7ef0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/dev/tty", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
close(3)                                = 0
write(2, "This application failed to start"..., 155This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".

Reinstalling the application may fix this problem.
) = 155
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1], [], 8) = 0
getpid()                                = 32718
gettid()                                = 32718
tgkill(32718, 32718, SIGABRT)           = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=32718, si_uid=0} ---
+++ killed by SIGABRT +++

Far as I can tell this is all I can do to try and tell it where to look for what it is searching for.

cat snapcraft.yaml 
name: rolisteam
version: "1.9.0"
summary: RPG Tabletop Manager
description: |
  Rolisteam is a virtual tabletop software. It helps you to manage 
  tabletop role playing games with remote friends/players. 
  It provides many features to share maps, pictures and it also 
  includes tool to communicate with your friends/players. 
  The goal is to make Rolisteam-managed RPG games as good as 
  RPG games around your table. 
  To achieve it, we are working hard to provide you more and more features. 


confinement: strict
base: core18

parts:
  rolisteam:
    plugin: qmake
    source-type: git
    source: https://github.com/Rolisteam/rolisteam.git
    build-packages:
      - qt5-default
      - qtbase5-dev-tools
      - qt5-qmake 
      - libqt5network5
      - zlib1g-dev 
      - build-essential
      - ca-certificates
      - qtmultimedia5-dev
      - libqt5core5a
      - libqt5gui5
      - qttools5-dev-tools
      - qtdeclarative5-dev
      - qtwebengine5-dev
      - libqt5svg5-dev         
    stage-packages:
      - libqt5network5
      - zlib1g
      - libqt5multimedia5
      - libqt5multimedia5-plugins
      - libqt5multimediaquick-p5
      - libqt5multimediawidgets5
      - libqt5core5a
      - libqt5gui5
      - libqt5webengine5
      - libqt5webenginewidgets5
      - libqt5svg5
      - libqt5xml5
      - libpulse0
      - qt5dxcb-plugin
apps:

  rolisteam:
    command: usr/local/bin/rolisteam
    environment: 
      "LD_LIBRARY_PATH": "$LD_LIBRARY_PATH:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/qt5/plugins/"



    plugs: 
      - home
      - network
      - pulseaudio
      - desktop
      - desktop-legacy
      - wayland
      - x11