Adding shared library dependencies to Flatpak

I’m trying to add a shared library dependency to a flatpak build but cannot get it to work. It seems like I must be missing something simple. Minimal example in this GitHub repo but reproduced below. The dependency is libportal.

I have the following manifest:

id: com.example.example
runtime: org.gnome.Platform
runtime-version: '47'
sdk: org.gnome.Sdk
command: example

finish-args:
  - --share=ipc
  - --device=dri
  - --socket=wayland
  - --socket=fallback-x11

modules:

  - name: libportal
    buildsystem: meson
    sources:
      - type: git
        url: https://github.com/flatpak/libportal
        tag: 0.9.0

  - name: example
    buildsystem: meson
    sources:
      - type: dir
        path: .

The meson.build for the main module is:

project('example', 'c',
          version: '0.1.0',
    meson_version: '>= 1.0.0',
  default_options: [ 'warning_level=2', 'werror=false', 'c_std=gnu11', ],
)

executable('example', 'example.c', dependencies: [dependency('libportal')])

with a trivial example.c source file. I then run:

flatpak-builder --user --force-clean --install builddir com.example.example.yaml

which builds libportal etc, but when it comes to building the main module, meson gives:

../meson.build:7:29: ERROR: Dependency "libportal" not found, tried pkgconfig and cmake

I’m not sure this is specific to libportal or just any shared library.

What do I do to make sure that dependencies that are installed as earlier modules can be found when building the main module?

What version of flatpak-builder is this? You need 1.4.4.

Thanks for the response @bbhtt! This is 1.4.2 (on Ubuntu 24.04). Let me try a later version then.

Remove .flatpak-builder before retrying with newer flatpak-builder.

Upgrading to 1.4.4 fixed it, so simple one in the end, thanks again for your help!

To add some more information for others straying this way, it looks to me like /app/lib64 became /app/lib in the sandbox between versions 1.4.2 and 1.4.4. That may break other things, for example I’m needing the dconf backend for GSettings, so had --env=GIO_EXTRA_MODULES=/app/lib64/gio/modules/ set in finish-args of the Flatpak manifest. That now needs to be --env=GIO_EXTRA_MODULES=/app/lib/gio/modules/.

This topic was automatically closed after 20 hours. New replies are no longer allowed.