Libraries added in stage-packages don't show up in the snap

I’m trying to add a plugin to the obs-studio snap. I have added this part:

  backscrub:
    plugin: cmake
    source: https://github.com/floe/backscrub.git
    source-branch: 'main'
    build-packages:
      - libopencv-dev
    stage-packages:
      - libopencv-core4.2
      - libopencv-highgui4.2
      - libopencv-imgcodecs4.2
      - libopencv-imgproc4.2
      - libopencv-videoio4.2
    cmake-parameters:
      - -DCMAKE_INSTALL_PREFIX=/usr
      - -DCMAKE_BUILD_TYPE=Release
      - -DCMAKE_C_FLAGS_RELEASE=-s
      - -DCMAKE_CXX_FLAGS_RELEASE=-s
      - -DLIBOBS_INCLUDE_DIR=$SNAPCRAFT_STAGE/usr/include/obs/
      - -DUSE_UBUNTU_FIX=TRUE
    prime:
      - -usr/lib/$SNAPCRAFT_ARCH_TRIPLET

As you can see, libopencv packages are listed in stage-packages. The snap builds correctly. When I try to run the backscrub program it outputs the following:

/snap/obs-studio/x6/usr/bin/backscrub: error while loading shared libraries: libopencv_highgui.so.4.2: cannot open shared object file: No such file or directory

Running find -iname '*opencv*' in the prime directory produces the following result:

./usr/share/doc/libopencv-imgproc4.2
./usr/share/doc/libopencv-videoio4.2
./usr/share/doc/libopencv-highgui4.2
./usr/share/doc/libopencv-core4.2
./usr/share/doc/libopencv-imgcodecs4.2

dpkg -S /usr/share/doc/libopencv-core4.2 produces the following output:

libopencv-core4.2:amd64: /usr/share/doc/libopencv-core4.2

So snapcraft has in fact added SOME of the files from the stage-packages to the snap. Just not any of the ones I need.

Why?

you are telling it to remove the library dir from your snap here … drop that and your libs should be in the snap …

2 Likes