Snap shared libraries mismatch

I did a trivial Qt5 app compiled using a recent Qt 5.9 from the qt.io web site. The CMake build system sets the rpath to find these libraries correctly at runtime without LD_LIBRARY_PATH. However, snapcraft copies the system libraries (Qt 5.5) instead, which causes the app to fail to run with the following error message:

/snap/18-patran-part/x5/bin/tst_patrantest: /snap/18-patran-part/x5/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.9' not found (required by /snap/18-patran-part/x5/bin/tst_patrantest)

I think it should instead list the libraries the executable is expecting, and not copy blindly the system’s library.

Well, I guess that the warning message says it all:

Files from the build host were migrated into the snap to satisfy dependencies that would otherwise not be met. This feature will be removed in a future release. If these libraries are needed in the final snap, ensure that the following are either satisfied by a stage-packages entry or through a part:

The workaround is to indicate to CMake to find the system’s Qt5 libraries, and not the default one that might be found in the path. This ensure the snapcraft will copy the same libraries as the ones that are used at link time.

For reference, here is a minimal example of a Qt5 app.

https://gitlab.com/fgiraldeau/snap-trivial-qt5

The only thing is that it uses an old Qt5 release. Can we use a PPA or customize the package repos for the stage-package and build-package?

It sounds like you’re building on a desktop system without using a clean container to prevent cross-contamination. Try using snapcraft cleanbuild instead, so that the Qt which you compile as part of your build will be the only one visible while building and packing.

1 Like