rainyl / opencv_dart

OpenCV bindings for Dart language and Flutter. Support Asynchronous Now!
https://pub.dev/packages/opencv_dart
Apache License 2.0
136 stars 18 forks source link

Failed to load `libavformat.so.58` on arch linux #218

Closed ferraridamiano closed 3 months ago

ferraridamiano commented 3 months ago

I am unable to run the example app on arch linux. I get the following error:

The following ArgumentError was thrown building MyApp(dirty, state: _MyAppState#d3a11):
Invalid argument(s): Failed to load dynamic library 'libopencv_dart.so': libavformat.so.58: cannot
open shared object file: No such file or directory

ffmpeg is installed, the libavformat file exists (I manually symlinked version 58 to 61):

$ ls -l /usr/lib/libavcodec*
lrwxrwxrwx 1 root root       22  3 lug 07.49 /usr/lib/libavcodec.so -> libavcodec.so.61.3.100
lrwxrwxrwx 1 root root       25 18 ago 18.07 /usr/lib/libavcodec.so.58 -> /usr/lib/libavcodec.so.61
lrwxrwxrwx 1 root root       22  3 lug 07.49 /usr/lib/libavcodec.so.61 -> libavcodec.so.61.3.100
-rwxr-xr-x 1 root root 16137176  3 lug 07.49 /usr/lib/libavcodec.so.61.3.100
rainyl commented 3 months ago

Sorry for the late reply, I am kind of busy recently.

Have you linked libavformat.so.58?

There are many Linux distributions, the prebuilt binaries for linux are built on Ubuntu 22.04, so the ffmpeg linked was ffmpeg 4.4, you can either build this package on ArchLinux by yourself or install ffmpeg 4.4.

I personally suggest you to download ffmpeg 4.4 or try to install ffmpeg4.4 https://archlinux.org/packages/extra/x86_64/ffmpeg4.4/ and then copy the required libraries such as libavformat.so.58 to the flutter output directory or to the directory of pub cache. (typically it should be ~/.pub-cache/hosted/pub.dev/opencv_dart-1.2.1/linux/, as you can see, https://github.com/rainyl/opencv_dart/blob/62d50b2a6b84d00ef58b1148c5db8610e4a4c8f8/linux/CMakeLists.txt#L61 , all .so inside linux will be copied to the output directory of flutter build)

ferraridamiano commented 3 months ago

Thank you, the fix was as easy as running pacman -S ffmpeg4.4