Closed CaptainDario closed 9 months ago
When looking at build-dir/files/lib
there is a libmpv.so
, a libmpv.so.2
and a libmpv.so.2.0.0
.
Am I building the wrong libmpv version?
my current building .json
can be found here
error while loading shared libraries: libmpv.so.1: cannot open shared object file: No such file or directory
Check your LD_LIBRARY_PATH
environment variable so that it points to the directory containing the library.
The name of the library is correct, as media_kit
supports the following names:
https://github.com/media-kit/media-kit/blob/97c2ab230df819b9ebc98b00b55468100faa50c1/media_kit/lib/src/player/native/core/native_library.dart#L48-L52
Hey I am currently shipping Spotube using Flatpak you can follow it's manifest if it helps
app-id: com.github.KRTirtho.Spotube
runtime: org.gnome.Platform
runtime-version: '44'
sdk: org.gnome.Sdk
command: spotube
finish-args:
- --socket=fallback-x11
- --socket=wayland
- --socket=pulseaudio #This might be needed
- --share=network
- --share=ipc
- --device=dri
- --filesystem=xdg-download
- --talk-name=org.freedesktop.Notifications
- --talk-name=org.kde.StatusNotifierWatcher
- --talk-name=org.freedesktop.secrets
- --filesystem=xdg-documents
- --filesystem=xdg-run/gvfs #This might be needed
- --filesystem=xdg-run/pipewire-0:ro #This might be needed
- --own-name=org.mpris.MediaPlayer2.spotube
- --system-talk-name=org.freedesktop.NetworkManager
modules:
- shared-modules/libappindicator/libappindicator-gtk3-12.10.json
- shared-modules/libsecret/libsecret.json
- name: libnotify
buildsystem: meson
config-opts:
- -Dtests=false
- -Dintrospection=disabled
- -Dgtk_doc=false
- -Ddocbook_docs=disabled
sources:
- type: archive
url: https://download.gnome.org/sources/libnotify/0.7/libnotify-0.7.8.tar.xz
sha256: 69209e0b663776a00c7b6c0e560302a8dbf66b2551d55616304f240bba66e18c
- name: jsoncpp
buildsystem: meson
config-opts:
- --default-library=shared
sources:
- type: git
url: https://github.com/open-source-parsers/jsoncpp
tag: 1.9.5
# These are the required dependencies
- name: libmpv
cleanup:
- /include
- /lib/pkgconfig
- /share/man
buildsystem: simple
build-commands:
- python3 waf configure --prefix=/app --enable-libmpv-shared --disable-cplayer --disable-build-date
--disable-alsa
- python3 waf build
- python3 waf install
sources:
- type: git
url: https://github.com/mpv-player/mpv.git
tag: v0.35.1
- type: file
url: https://waf.io/waf-2.0.25
sha256: 21199cd220ccf60434133e1fd2ab8c8e5217c3799199c82722543970dc8e38d5
dest-filename: waf
modules:
- name: libass
cleanup:
- /include
- /lib/*.la
- /lib/pkgconfig
config-opts:
- --disable-static
sources:
- type: archive
url: https://github.com/libass/libass/releases/download/0.17.1/libass-0.17.1.tar.xz
sha256: f0da0bbfba476c16ae3e1cfd862256d30915911f7abaa1b16ce62ee653192784
modules:
- name: fribidi
cleanup:
- /bin
- /include
- /lib/pkgconfig
- /lib/*.la
- /share/man
buildsystem: meson
config-opts:
- --buildtype=release
- -Ddocs=false
sources:
- type: git
url: https://github.com/fribidi/fribidi.git
tag: v1.0.13
commit: b54871c339dabb7434718da3fed2fa63320997e5
- name: x264
cleanup:
- /include
- /lib/pkgconfig
- /share/man
config-opts:
- --disable-cli
- --enable-shared
sources:
- type: git
url: https://code.videolan.org/videolan/x264.git
commit: a8b68ebfaa68621b5ac8907610d3335971839d52
x-checker-data:
type: json
url: https://code.videolan.org/api/v4/projects/536/repository/commits
commit-query: first( .[].id )
version-query: first( .[].id )
timestamp-query: first( .[].committed_date )
- name: nv-codec-headers
cleanup:
- '*'
no-autogen: true
make-install-args:
- PREFIX=/app
sources:
- type: git
url: https://github.com/FFmpeg/nv-codec-headers.git
commit: 855f8263d97bbdcaeabaaaa2997e1ccad7c52dc3
- name: ffmpeg
cleanup:
- /include
- /lib/pkgconfig
- /share/ffmpeg/examples
config-opts:
- --enable-shared
- --disable-static
- --enable-gnutls
- --disable-doc
- --disable-programs
- --disable-encoders
- --disable-muxers
- --enable-encoder=png
- --enable-libv4l2
- --enable-libdav1d
sources:
- type: git
url: https://git.ffmpeg.org/ffmpeg.git
branch: release/6.0
commit: 3d5edb89e75fe3ab3a6757208ef121fa2b0f54c7
# -----------------------------------------------------------------------------------
- name: spotube
buildsystem: simple
build-commands:
- install -Dm644 spotube/com.github.KRTirtho.Spotube.appdata.xml /app/share/appdata/com.github.KRTirtho.Spotube.appdata.xml
- desktop-file-edit spotube/spotube.desktop --set-key=Exec --set-value="spotube
%u" --set-icon=com.github.KRTirtho.Spotube
- install -Dm644 spotube/spotube-logo.png /app/share/icons/hicolor/128x128/apps/com.github.KRTirtho.Spotube.png
- install -Dm644 spotube/spotube.desktop /app/share/applications/com.github.KRTirtho.Spotube.desktop
- install -dm755 /app/bin /app/spotube
- cp -R spotube/ /app
- ln -s /app/spotube/spotube /app/bin/spotube
sources:
- type: archive
dest: spotube
url: https://github.com/KRTirtho/spotube/releases/download/v3.1.0/spotube-linux-3.1.0-x86_64.tar.xz
sha256: d9b38e7b57b04c17822541d122292c461a8db824f1bd10bdc82c23840593f30b
I consider this as solved. Closing.
The discussion is left open in-case any further conversation is required.
Thanks!
@KRTirtho I tried copying your file and adapting it to my file structure. But I am still hitting
error while loading shared libraries: libmpv.so.1: cannot open shared object file: No such file or directory
I build the flatpak like this
# building flutter app
flutter build linux --release
# zip and copy the application to the flatpak directory
...
# build flatpak
flatpak-builder --force-clean build-dir com.DaAppLab.DaKanji.yaml --repo=repo
flatpak build-bundle repo com.DaAppLab.DaKanji.flatpak com.DaAppLab.DaKanji
# install flatpak
flatpak install com.DaAppLab.DaKanji.flatpak
The app installs just fine and the icon also shows up in my applications. However, during runtime I encounter the mentioned issue.
Do you have any idea what I am missing? My build .yaml
:
app-id: com.DaAppLab.DaKanji
runtime: org.gnome.Platform
runtime-version: '44'
sdk: org.gnome.Sdk
command: DaKanji
finish-args:
- --socket=fallback-x11
- --socket=wayland
- --socket=pulseaudio #This might be needed
- --share=network
- --share=ipc
- --device=dri
- --filesystem=xdg-download
- --talk-name=org.freedesktop.Notifications
- --talk-name=org.kde.StatusNotifierWatcher
- --talk-name=org.freedesktop.secrets
- --filesystem=xdg-documents
- --filesystem=xdg-run/gvfs #This might be needed
- --filesystem=xdg-run/pipewire-0:ro #This might be needed
- --own-name=org.mpris.MediaPlayer2.spotube
- --system-talk-name=org.freedesktop.NetworkManager
modules:
# These are the required dependencies
- name: libmpv
cleanup:
- /include
- /lib/pkgconfig
- /share/man
buildsystem: simple
build-commands:
- python3 waf configure --prefix=/app --enable-libmpv-shared --disable-cplayer --disable-build-date
--disable-alsa
- python3 waf build
- python3 waf install
sources:
- type: git
url: https://github.com/mpv-player/mpv.git
tag: v0.35.1
- type: file
url: https://waf.io/waf-2.0.25
sha256: 21199cd220ccf60434133e1fd2ab8c8e5217c3799199c82722543970dc8e38d5
dest-filename: waf
modules:
- name: libass
cleanup:
- /include
- /lib/*.la
- /lib/pkgconfig
config-opts:
- --disable-static
sources:
- type: archive
url: https://github.com/libass/libass/releases/download/0.17.1/libass-0.17.1.tar.xz
sha256: f0da0bbfba476c16ae3e1cfd862256d30915911f7abaa1b16ce62ee653192784
modules:
- name: fribidi
cleanup:
- /bin
- /include
- /lib/pkgconfig
- /lib/*.la
- /share/man
buildsystem: meson
config-opts:
- --buildtype=release
- -Ddocs=false
sources:
- type: git
url: https://github.com/fribidi/fribidi.git
tag: v1.0.13
commit: b54871c339dabb7434718da3fed2fa63320997e5
- name: x264
cleanup:
- /include
- /lib/pkgconfig
- /share/man
config-opts:
- --disable-cli
- --enable-shared
sources:
- type: git
url: https://code.videolan.org/videolan/x264.git
commit: a8b68ebfaa68621b5ac8907610d3335971839d52
x-checker-data:
type: json
url: https://code.videolan.org/api/v4/projects/536/repository/commits
commit-query: first( .[].id )
version-query: first( .[].id )
timestamp-query: first( .[].committed_date )
- name: nv-codec-headers
cleanup:
- '*'
no-autogen: true
make-install-args:
- PREFIX=/app
sources:
- type: git
url: https://github.com/FFmpeg/nv-codec-headers.git
commit: 855f8263d97bbdcaeabaaaa2997e1ccad7c52dc3
- name: ffmpeg
cleanup:
- /include
- /lib/pkgconfig
- /share/ffmpeg/examples
config-opts:
- --enable-shared
- --disable-static
- --enable-gnutls
- --disable-doc
- --disable-programs
- --disable-encoders
- --disable-muxers
- --enable-encoder=png
- --enable-libv4l2
- --enable-libdav1d
sources:
- type: git
url: https://git.ffmpeg.org/ffmpeg.git
branch: release/6.0
commit: 3d5edb89e75fe3ab3a6757208ef121fa2b0f54c7
# -----------------------------------------------------------------------------------
- name: DaKanji
buildsystem: simple
build-commands:
- pwd
- ls DaKanji -la
- install -Dm644 DaKanji/com.DaAppLab.DaKanji.appdata.xml /app/share/appdata/com.DaAppLab.DaKanji.appdata.xml
#- desktop-file-edit DaKanji/DaKanji.desktop --set-key=Exec --set-value="dakanji %u" --set-icon=com.DaAppLab.DaKanji
- install -Dm644 DaKanji/LaunchImage@2x.png /app/share/icons/hicolor/512x512/apps/com.DaAppLab.DaKanji.png
- install -Dm644 DaKanji/DaKanji.desktop /app/share/applications/com.DaAppLab.DaKanji.desktop
- install -dm755 /app/bin /app/DaKanji
- cp -R DaKanji/ /app
- ln -s /app/DaKanji/DaKanji /app/bin/DaKanji
sources:
- type: archive
path: bundle.zip
dest: DaKanji
- type: file
path: com.DaAppLab.DaKanji.appdata.xml
dest: DaKanji
- type: file
path: DaKanji.desktop
dest: DaKanji
- type: file
path: ../ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
dest: DaKanji
We provide a libmpv
argument in MediaKit.ensureInitialized
.
Maybe see if the application was launched from Flatpak & pass the applicable path. Many applications I've seen do it.
Also, I wanted to warn (my past experience) that applications that run through Flatpak are sandboxed. It means that cache etc. can't be saved unless some permissions etc. are declared. Unfortunately I don't know which ones. I decided to stop since it brought more maintenance cost & potential bugs for me in my limited time, I rather have stability.
As long as media_kit is using standard cache directories like ~/.cache or ~/.local/share/
@KRTirtho can you tell me the commands you use to build the flatpak? I am at a loss here.
Yeah those linux packaging formats are a real pain.
Well, I always use this command for Spotube:
$ flatpak-builder --user --install --force-clean build com.github.KRTirtho.Spotube.yml
Judging from the CaptainDario/DaKanji/.github/workflows/linux_test_and_build.yml file, I see that you're directly using upload-artifacts to make a bundle zip Remember, upload-artifacts doesn't preserve file permissions & it might also mess up dynamic linking of media_kit shared objects (not sure though)
Did you try with a bundle.zip locally?
Tip: flutter_distributor will make it easier to package apps
The workflow is currently not in use as there are waaay too many problems. Wow! Did not know about flutter distributor. If it enables me to build all my packages this would be such a life saver! But it does not support flatpak?
Yes, I am currently trying using a local build. Following this
# building flutter app
flutter build linux --release
# zip and copy the application to the flatpak directory
...
# build flatpak
flatpak-builder --force-clean build-dir com.DaAppLab.DaKanji.yaml --repo=repo
flatpak build-bundle repo com.DaAppLab.DaKanji.flatpak com.DaAppLab.DaKanji
# install flatpak
flatpak install com.DaAppLab.DaKanji.flatpak
I am now encountering flutter not being able to find some libs that are in the bundle itseld : bundle/lib/
error while loading shared libraries: libclipboard_watcher_plugin.so: cannot open shared object file: No such file or directory
when shelling into the environment the libraries are there
~/dev/dakanji/flatpak$ flatpak run --devel --command=sh com.DaAppLab.DaKanji
[📦 com.DaAppLab.DaKanji ~]$ ls /app/DaKanji/
com.DaAppLab.DaKanji.appdata.xml libapp.so libmecab_dart_plugin.so libscreen_retriever_plugin.so
DaKanji libclipboard_watcher_plugin.so libmedia_kit_libs_linux_plugin.so libsentry_flutter_plugin.so
DaKanji.desktop libflutter_linux_gtk.so libmedia_kit_native_event_loop.so libtensorflowlite_c-linux.so
flutter_assets libgtk_plugin.so libmedia_kit_video_plugin.so liburl_launcher_linux_plugin.so
icudtl.dat libisar_flutter_libs_plugin.so libpdfium.so libwindow_manager_plugin.so
LaunchImage@2x.png libisar.so libprinting_plugin.so
So it seems like all the libraries paths are somehow not correct...
Yup. The shared objects (*.so) should be inside /app/DaKanji/lib
For reference here's how Spotube's look:
[📦 com.github.KRTirtho.Spotube app]$ ls /app
bin include lib manifest.json share spotube
[📦 com.github.KRTirtho.Spotube app]$ ls /app/spotube/
com.github.KRTirtho.Spotube.appdata.xml lib spotube.desktop
data spotube spotube-logo.png
Well back to one. Again
DaKanji: error while loading shared libraries: libmpv.so.1: cannot open shared object file: No such file or directory
What I do not get is, when I run the app as the portable output from flutter I get this output (I hard coded the path for now)
./DaKanji
package:media_kit_libs_linux registered.
flutter: TESTING IF THIS PRINTS
flutter:
--------------------------------------------------------------------------------
media_kit: ERROR: MediaKit.ensureInitialized
This indicates that one or more required dependencies could not be located.
Refer to "Installation" section of the README for further details:
GitHub : https://github.com/media-kit/media-kit#installation
pub.dev : https://pub.dev/packages/media_kit#installation
TIP: Copy-paste required packages from the above link to your pubspec.yaml.
If you recently added the packages, make sure to re-run the project ("hot-restart" & "hot-reload" is not sufficient for native plugins).
--------------------------------------------------------------------------------
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Invalid argument(s): Failed to load dynamic library '/app/lib/libmpv.so.2': /app/lib/libmpv.so.2: cannot open shared object file: No such file or directory
#0 _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:11)
#1 new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:22)
#2 NativeLibrary.ensureInitialized (package:media_kit/src/player/native/core/native_library.dart:33)
#3 nativeEnsureInitialized (package:media_kit/src/player/native/player/real.dart:47)
#4 MediaKit.ensureInitialized (package:media_kit/src/media_kit.dart:26)
#5 main (package:da_kanji_mobile/main.dart:25)
#6 _runMain.<anonymous closure> (dart:ui/hooks.dart:131)
#7 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:296)
#8 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189)
Why is the output not atleast the same...
I also now checked spotube (btw you got a new user)
[📦 com.github.KRTirtho.Spotube ~]$ ls /app/lib/
debug libavdevice.so.60.1.100 libdbus-glib-1.so.2.3.5 libindicator3.so.7.0.0 libswresample.so
libappindicator3.so libavfilter.so libdbusmenu-glib.so libjsoncpp.so libswresample.so.4
libappindicator3.so.1 libavfilter.so.9 libdbusmenu-glib.so.4 libjsoncpp.so.25 libswresample.so.4.10.100
libappindicator3.so.1.0.0 libavfilter.so.9.3.100 libdbusmenu-glib.so.4.0.12 libmpv.so libswscale.so
libass.so libavformat.so libdbusmenu-gtk3.so libmpv.so.2 libswscale.so.7
libass.so.9 libavformat.so.60 libdbusmenu-gtk3.so.4 libmpv.so.2.0.0 libswscale.so.7.1.100
libass.so.9.2.1 libavformat.so.60.3.100 libdbusmenu-gtk3.so.4.0.12 libnotify.so libx264.so
libavcodec.so libavutil.so libfribidi.so libnotify.so.4 libx264.so.164
libavcodec.so.60 libavutil.so.58 libfribidi.so.0 libnotify.so.4.0.0 pkgconfig
libavcodec.so.60.3.100 libavutil.so.58.2.100 libfribidi.so.0.4.0 libsecret-1.so
libavdevice.so libdbus-glib-1.so libindicator3.so libsecret-1.so.0
libavdevice.so.60 libdbus-glib-1.so.2 libindicator3.so.7 libsecret-1.so.0.0.0
DaKanji, I really do not get why i t cannot find it
[📦 com.DaAppLab.DaKanji ~]$ ls /app/lib/
debug libavcodec.so.60.3.100 libavfilter.so.9.3.100 libavutil.so.58.2.100 libmpv.so.2.0.0 libswscale.so.7.1.100
libass.so libavdevice.so libavformat.so libfribidi.so libswresample.so libx264.so
libass.so.9 libavdevice.so.60 libavformat.so.60 libfribidi.so.0 libswresample.so.4 libx264.so.164
libass.so.9.2.1 libavdevice.so.60.1.100 libavformat.so.60.3.100 libfribidi.so.0.4.0 libswresample.so.4.10.100
libavcodec.so libavfilter.so libavutil.so libmpv.so libswscale.so
libavcodec.so.60 libavfilter.so.9 libavutil.so.58 libmpv.so.2 libswscale.so.7
This is the problem I tried to highlight
when shelling into the environment the libraries are there
~/dev/dakanji/flatpak$ flatpak run --devel --command=sh com.DaAppLab.DaKanji [📦 com.DaAppLab.DaKanji ~]$ ls /app/DaKanji/ com.DaAppLab.DaKanji.appdata.xml libapp.so libmecab_dart_plugin.so libscreen_retriever_plugin.so DaKanji libclipboard_watcher_plugin.so libmedia_kit_libs_linux_plugin.so libsentry_flutter_plugin.so DaKanji.desktop libflutter_linux_gtk.so libmedia_kit_native_event_loop.so libtensorflowlite_c-linux.so flutter_assets libgtk_plugin.so libmedia_kit_video_plugin.so liburl_launcher_linux_plugin.so icudtl.dat libisar_flutter_libs_plugin.so libpdfium.so libwindow_manager_plugin.so LaunchImage@2x.png libisar.so libprinting_plugin.so
Answer:
Yup. The shared objects (*.so) should be inside
/app/DaKanji/lib
For reference here's how Spotube's look:
[📦 com.github.KRTirtho.Spotube app]$ ls /app bin include lib manifest.json share spotube [📦 com.github.KRTirtho.Spotube app]$ ls /app/spotube/ com.github.KRTirtho.Spotube.appdata.xml lib spotube.desktop data spotube spotube-logo.png
Ah sorry, I wasn't clear. After cleaning everything and rebuilding etc. the flutter libs are now in /app/DaKanji/lib.
And now it cannot find the libmpv.so again ...
This soon turned into a mystery :sweat_smile:
Ok this is the last resort ig. If it doesn't work I'm done :joy:
try running your app with
$ flatpak run --env="LD_LIBRARY_PATH=/app/lib" com.DaAppLab.DaKanji
Thank you a lot for your help but this also does not help. Guess DaKanji needs to continue without flatpak Edit: really werird, as spotube works for me
@KRTirtho success! Adding
- cp /app/lib/libmpv.so /app/lib/libmpv.so.1
and running via flatpak run --socket=session-bus --env="LD_LIBRARY_PATH=/app/lib/" com.DaAppLab.DaKanji
made it work.
Do you have any idea how to integrate -env="LD_LIBRARY_PATH=/app/lib/"
into the building phase?
@birros doess media-kit check for libmpv.so.1
somwhere else?
The app crashes before calling MediaKit.ensureInitialized(libmpv: "/app/lib/libmpv.so.2");
.
When I do
cp /app/lib/libmpv.so.2 /app/lib/libmpv.so.1
it works.
In the file you mentioned the error message also seems to be a different one
compared to
error while loading shared libraries: libmpv.so.1: cannot open shared object file: No such file or directory
Do you have any idea how to integrate
-env="LD_LIBRARY_PATH=/app/lib/"
into the building phase?
For anybody stumbling upon this, it's possible like this
finish-args:
- ...
- --env=LD_LIBRARY_PATH=/app/lib
Thanks again for this awesome package!
I am trying to bundle my app using flatpak but I am constantly hitting
I tried to follow the setup that the project that is recommended uses. The processes compiles a lot of stuff but it seems like it is still missing the necessary library.
Do you have any pointers how to get a flatpak running?
Additionally, it would be really nice to get a list of dependencies or smth that medikit uses in its libmpv build. mpv compilation lists a lot of optional packages, which of them are necessary?
Thank you very much!