javacflatpakflatpak-builder

Flatpak build missing Gtk .so dependencies


I have a Java project that uses Java-GI Gtk/Adw bindings. It uses the maven-flatpak-plugin to generate a .desktop, metainfo.xml and .yml manifest. Then I run flatpak-builder:

sudo flatpak-builder --force-clean --verbose --install build-dir ca.footeware.java.texty3.yml

...and it seems to install fine. Running it however, causes the error:

java.lang.UnsatisfiedLinkError: no libgtk-4.so.1 in java.library.path: :/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib

So the flatpak container was missing dependencies on the Gtk libraries, a dependency of Java-GI. I copied the .so files into the /app/share folder during install. I found libgtk-4.so.1 on the host and copied it into the container using the yml manifest:

  - "install -D libgtk-4.so.1 /app/share/libgtk-4.so.1"
  ...
  - type: "file"
    path: "../../src/flatpak/lib/libgtk-4.so.1"
  ...
  - "--env=LD_LIBRARY_PATH=/app/share:/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib"

Rebuilt and reinstalled and got a different error:

java.lang.UnsatisfiedLinkError: /app/share/libgtk-4.so.1: /app/share/libgtk-4.so.1: undefined symbol: pango_font_map_add_font_file

I think this indicates it found the gtk.so. I did a similar search for pango and found libpangocairo-1.0.so.0.5600.3 and similarly copied it into /app/share and confirmed its presence. Rebuilt and reinstalled and got the same error. I read that the pango_font_map_add_font_file symbol was introduced in 1.55 and I verified that libpangocairo-1.0.so.0.5600.3 is version 1.56.

Two questions:

  1. Is this the best strategy? I feel like I'm reinstalling all the Gtk libraries. There must be a simpler way to meet the dependencies.
  2. If this is the correct thing to do, how do I make libgtk-4.so.1 in /app/share see libpangocairo-1.0.so in the same folder?

Solution

  • Thanks to @bbhtt over on Flatpak Matrix. He said I should use org.gnome.Platform and org.gnome.Sdk rather than the freedesktop runtimes because they already have Gtk installed.