Hello!
I’m trying to add ffmpeg (and mpv) to a snap I’m building (see Snapcraft recipe).
The snap builds, but when I snap run --shell
into it, I cannot execute ffmpeg:
$ ffmpeg
ffmpeg: error while loading shared libraries: libblas.so.3: cannot open shared object file: No such file or directory
This file is present in my snap, in /snap/checkbox-kivu-classic/current/usr/lib/x86_64-linux-gnu/blas/libblas.so.3
.
To try to understand what was going on, I installed ffmpeg from the repos using sudo apt install ffmpeg
. After installation, I can see the following:
$ ll /usr/lib/x86_64-linux-gnu/libblas.so.3
lrwxrwxrwx 1 root root 47 Nov 27 2022 /usr/lib/x86_64-linux-gnu/libblas.so.3 -> /etc/alternatives/libblas.so.3-x86_64-linux-gnu
But in my snap, there is no such symlink:
$ ll /snap/checkbox-kivu-classic/current/usr/lib/x86_64-linux-gnu/libblas.so.3
ls: cannot access '/snap/checkbox-kivu-classic/current/usr/lib/x86_64-linux-gnu/libblas.so.3': No such file or directory
If I manually append the path to LD_LIBRARY_PATH
, ffmpeg finds it, but then chokes on the next library it requires:
$ echo $LD_LIBRARY_PATH
/var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void:/snap/checkbox-kivu-classic/x3/lib:/snap/checkbox-kivu-classic/x3/usr/lib:/snap/checkbox-kivu-classic/x3/usr/lib/x86_64-linux-gnu:/snap/checkbox22/current/lib:/snap/checkbox22/current/lib/x86_64-linux-gnu:/snap/checkbox22/current/usr/lib/x86_64-linux-gnu:/snap/checkbox22/current/lib/fwts
$ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/snap/checkbox-kivu-classic/current/usr/lib/x86_64-linux-gnu/blas ffmpeg
ffmpeg: error while loading shared libraries: liblapack.so.3: cannot open shared object file: No such file or directory
If I keep doing that for every library, I can eventually run the ffmpeg
command:
$ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/snap/checkbox-kivu-classic/current/usr/lib/x86_64-linux-gnu/blas:/snap/checkbox-kivu-classic/current/usr/lib/x86_64-linux-gnu/lapack ffmpeg
ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
Use -h to get full help or, even better, run 'man ffmpeg'
Two questions:
- Is it normal that a package like ffmpeg added through
stage-packages
properly installs its dependencies, but fails to create the appropriate symlinks? - As a workaround, should I add the following to each of my apps’ sections?
environment:
LD_LIBRARY_PATH: $LD_LIBRARY_PATH:$SNAP/lib/$CRAFT_ARCH_TRIPLET/blas:$SNAP/lib/$CRAFT_ARCH_TRIPLET/lapack
Thanks in advance!