Connect interface for external snap with libraries

Hi all.
All libraries and Qt modules I selected in a separate snap package.
All slots declared as follows:

 slots:
 qt5libs:
 content: qt5libs0
 interface: content
 read:
 - QT/5.5/gcc_64/lib
 qt5qml:
 content: qt5qml0
 interface: content
 read:
 - QT/5.5/gcc_64/qml
 qt5plugins:
 content: qt5plugins0
 interface: content
 read:
 - QT/5.5/gcc_64/plugins
 qt5platforms:
 content: qt5platforms0
 interface: content
 read:
 - QT/5.5/gcc_64/plugins/platforms

It is through such paths that all libraries and modules are located
On the side of the snap that should be connected to these slots all the plugins are declared so:

plugs:
qt5libs:
content: qt5libs0
default-provider: qt5libs:qt5libs
interface: content
target: qt5libs
qt5plugins:
content: qt5plugins0
default-provider: qt5plugins:qt5plugins
interface: content
target: qt5plugins
qt5qml:
content: qt5plugins0
default-provider: qt5plugins:qt5plugins
interface: content
target: qt5plugins
qt5platforms:
content: qt5platforms0
default-provider: qt5platforms:qt5platforms
interface: content
target: qt5platforms

In the script to run the application, I wrote these lines to find modules and libraries:

export QT5LIBS=${SNAP}/qt5libs
export QT5PLUGINS=${SNAP}/qt5plugins
export QT5QML=${SNAP}/qt5qml
export QT5PLATFORMS=${SNAP}/qt5platforms

export LD_LIBRARY_PATH="${QT5LIBS}:$LD_LIBRARY_PATH"
export QT_PLUGIN_PATH=${QT5PLUGINS}
export QML2_IMPORT_PATH="${QT5QML}:$QML2_IMPORT_PATH"
export QT_QPA_PLATFORM_PLUGIN_PATH=${QT5PLATFORMS}

When I try to start I see an error, does not find the plugin XCB.
Connect to plug-ins go through without errors
sudo snap connect bsp095project:qt5qml qtlibraries:qt5qml
I assume that I have incorrectly path, can anyone tell me where I could be wrong?

Hey!

Not sure if this is related to any of the problems but can you please ensure you prefix those with $SNAP. The prefix-less syntax was used in the initial and old version of snapd and may be rejected at some time in the future.

At the moment I’m trying in a same way to take Qt libraries into a separate snap package.
The same situation, connect have, but the plugins did not find.

This application failed to start because it could not find or load the Qt platform plugin "xcb".
Available platform plugins are: linuxfb, minimal, offscreen, xcb.
Reinstalling the application may fix this problem.

Can you do this please:

sudo nsenter -m/run/snapd/ns/$SNAP.mnt
cat /proc/self/mountinfo

Attach the output here:

I do not know how the author of this topic, but my log is like this:

48 25 7:0 / /snap/qtlibraries/x1 ro,nodev,relatime shared:29 - squashfs /dev/loop0 ro
70 25 7:13 / /snap/bsp095x11/x1 ro,nodev,relatime shared:155 - squashfs /dev/loop13 ro
102 121 0:3 mnt:[4026532418] /run/snapd/ns/bsp095x11.mnt rw - nsfs nsfs rw

snap interface:

Slot                                    Plug
qtlibraries:qt5libs                     bsp095x11
qtlibraries:qt5platforms                bsp095x11
qtlibraries:qt5plugins                  bsp095x11
qtlibraries:qt5qml                      bsp095x11
-                                       bsp095x11:camera
-                                       bsp095x11:raw-usb
-                                       bsp095x11:serial-port
-                                       mircade:mir

This is measured on the outside. I absolutely need the internal measurement. When you use nsenter as I described you will switch to a different mount namespace with different things mounted.

Sorry, my mistake

348 77 7:0 / /var/lib/snapd/hostfs/snap/qtlibraries/x1 ro,nodev,relatime master:29 - squashfs /dev/loop0 ro
376 77 7:13 / /var/lib/snapd/hostfs/snap/bsp095x11/x1 ro,nodev,relatime master:155 - squashfs /dev/loop13 ro
404 76 7:5 / / ro,nodev,relatime master:36 - squashfs /dev/loop5 ro
...
462 449 7:0 / /snap/qtlibraries/x1 ro,nodev,relatime master:29 - squashfs /dev/loop0 ro
463 449 7:13 / /snap/bsp095x11/x1 ro,nodev,relatime master:155 - squashfs /dev/loop13 ro
464 436 8:7 /var/lib/snapd/hostfs /var/lib/snapd/hostfs rw,relatime - ext4 /dev/sda7 rw,errors=remount-ro,data=ordered
78 433 8:7 /tmp/snap.0_bsp095x11_89OQzC/tmp /tmp rw,relatime - ext4 /dev/sda7 rw,errors=remount-ro,data=ordered
...

Now there is more information.

Hello, @zyga-snapd

Sorry for the late answer.

In fact, I have the same output like Blin.
Tell me, how do I understand when I write in snapkraft.yaml such a slot:
slots:
5libs:
content: 5libs0
interface: content
read:
- $SNAP/5.9.1/gcc_64/lib
This means that there will be a name for the 5libs slot that will access the $SNAP/5.9.1/gcc_64/lib path
And is it connected, then we like to get access to the files that are stored in … /lib?

Then on the side of the snap package that you want to access this slot, you create plug-ins

plugs:
    5libs:
        content: 5libs0
        default-provider: 5libs:5libs
        interface: content
        target: 5libs

And if there is a directory named 5libs and the connection is normal, then we will access the files from the slot $SNAP/5.9.1/gcc_64/lib
I understand correctly?

If this is so then how can I see if there are files in the directory 5libs on the side of the snap package with plugs after the connection?
Thank you.

I have never used the content interface before, so take this hint with a gain of salt, but i would expect if the interface is properly connected you should be able to run your consumer app like:

snap run --shell <appname>

that usually spawns a shell in the envirnoment the app sees when it is run, so there you should be able to see $SNAP/5libs/ (or $SNAP_DATA/5libs, not sure what the exact mountpoint is, as i said, i’m guessing :slight_smile: )

1 Like

Here’s a vanilla example of one way to use the interface https://github.com/snapcore/snapcraft/tree/master/demos/shared-ros

Take notice that in this example, the snap that provides the content has its stage component tared up to become the “sdk” for the consuming snap.

@zyga-snapd You got a response to your question above some days ago. Not sure if you’ve exchanged further info about it elsewhere? Can you please update here with the details.

Also, this says “upcoming”, but nothing above hints about what would in fact be upcoming. We should probably avoid tagging topics for work until we can correctly identify what the work is, or at least what needs to be fixed.