I am trying to crate a snap for a program that uses the libexiv2 library. The system I am using runs Xubuntu 20.10 and has libexiv2-27 installed. The relevant parts of the .yaml file are:
Running this gives the error message: Failed to fetch stage packages: Error downloading packages for part 'geeqie': The package 'libexiv2-27' was not found..
If I change the .yaml file to be:
stage-packages:
- libexiv2-14
the snap is created, but running the snap gives the message: error while loading shared libraries: libexiv2.so.14: cannot open shared object file: No such file or directory
Can anyone give me an idea of where the problem lies?
Thanks…
If you’re using base: core18 and building with snapcraft (multipass) or snapcraft --use-lxd (lxd) then you’ll be building against the Ubuntu 18.04 repo. libexiv2-27 only exists in 20.04 and above, as can be found via https://packages.ubuntu.com/search?keywords=libexiv2-27
According to the filelist for that package, the library should be in /usr/lib/x86_64-linux-gnu/. So, once installed, does /snap/geeqie/current/usr/lib/x86_64-linux-gnu/libexiv2.so.14 exist? If so, it should be found, unless there’s something else in the snapcraft.yaml preventing that. Could you please paste the entire yaml?
Thanks. So I need to have libexiv2-14 installed on the system I am compiling on.
This is the first snap I have tried to create, and am unsure of several aspects e.g. when using core18 is it typical to development to be done on a system that has 18.04 installed?
Thanks for your initial fast response! Sorry for my lack of understanding the basics.
I just used your yaml, with libexiv2-27 replaced with libexiv2-14 and ran snapcraft --use-lxd which build the application successfully and runs fine for me with the --disable-clutter option.
You do not need libexiv2-14 on the system you are hosting Snapcraft on. The reason exiv2-14 is needed in stage packages, is because the snap is being built against Ubuntu 18.04.
The default for Snapcraft is to make an environment, whether by Virtual Machine (Multipass), or LXD with the --use-lxd paramaters, that mirrors the environment of the base snap. (I.E, it’ll literally download a lot of Ubuntu 18.04 if you choose to use Core18 base). Both of these are detatched from your host OS that is running Snapcraft. All the building is done in the VM or the LXD container.
As such, when you are building a core18 snap, it derives packages from the Core18 repository. It does not matter what version of Ubuntu you are on, or that you’re on Ubuntu at all. This is why libexiv2-27 wasn’t found. The snap you are building had access to 18.04s repositories, not 20.04.
It is not required nor assumed that you run Snapcraft on the system that matches the base snap.
It is possible to use the host system as a build environment, but that is advanced functionality that has few practical uses and is not generally recommended.