Flatpak-builder - how to reference an external lib

Hi all,

I am trying to package Omnissa (formerly VMWare) Horizon Client but having issues with referencing external libraries.

Here is my yaml

---
app-id: com.omnissa.HorizonClient
runtime: org.freedesktop.Platform
runtime-version: '25.08'
sdk: org.freedesktop.Sdk
command: horizon-client
finish-args:
  - --share=network
  - --socket=wayland
  - --socket=pulseaudio
  - --device=all
  - --env=GTK_THEME=Adwaita
  - --persist=.omnissa

modules:
  - name: omnissa-horizon-client
    buildsystem: simple
    sources:
      - type: file
        url: https://download3.omnissa.com/software/CART26FQ2_LIN_2506_TARBALL/Omnissa-Horizon-Client-Linux-2506-8.16.0-16536624989.tar.gz
        sha256: 5515e79188e2605ced5a95c3a3829865b567be5d7a8de00a57455f7b5b2ae392
        dest-filename: Omnissa-Horizon-Client-Linux.tar.gz
    build-commands:
      - mkdir Extracted
      - tar -xf Omnissa-Horizon-Client-Linux.tar.gz -C Extracted --strip-components 1
      - tar -xf Extracted/x64/Omnissa-Horizon-Client-2506-8.16.0-16536624989.x64.tar.gz -C /app/ --strip-components 1
      - tar -xf Extracted/x64/Omnissa-Horizon-PCoIP-2506-8.16.0-16536624989.x64.tar.gz -C /app/ --strip-components 1
      - mkdir -p "/app/share/icons/hicolor/64x64/apps/"
      - mv "/app/usr/share/icons/horizon-client.png" "/app/share/icons/hicolor/64x64/apps/com.omnissa.HorizonClient.png"
      - mkdir -p "/app/share/applications/"
      - mv "/app/usr/share/applications/horizon-client.desktop" "/app/share/applications/com.omnissa.HorizonClient.desktop"
      - sed -i 's+/usr/share/icons/horizon-client.png+com.omnissa.HorizonClient+' "/app/share/applications/com.omnissa.HorizonClient.desktop"
      - mkdir /app/bin/
      - mv /app/usr/bin/* /app/bin
      - mkdir /app/lib/
      - mv /app/usr/lib/* /app/lib
      - for f in `find /app/bin/ -not -type d`; do sed -i 's+/usr+/app+' "$f"; done
      - for f in `find /app/lib/omnissa/ -not -type d`; do sed -i 's+/usr+/app+' "$f"; done
      - ln -s /lib/x86_64-linux-gnu/libxml2.so.2 /app/lib/libxml2.so.2

The last line is setting up a symbolic link to a system library (libxml2.so.2) and I can see the link looks fine in build-dir/lib but, when I try to run the installed app, I get the error

/app/lib/omnissa/horizon/bin/horizon-client: error while loading shared libraries: libxml2.so.2: cannot open shared object file: No such file or directory

Any ideas?

If linking to external libs is a nono can I instead link to the equivalent lib in the runtime? How would I do that?

TIA

Since Flatpak applications are run inside an sandbox, they can’t access access files on the system by design.
The symbolic just don’t resolve inside the sandbox.

If you need a library, build and add it to the Flatpak as a module. Then you’d likely also wouldnt need the symbolic link.

As another point:
There are distribution out there who dont even use /lib anymore. Nowadays, it should be inside this prefix /usr.

So even if Flatpak would allow access to the system, this wouldn’t work on all systems. Not to mention that not every system might have your library installed, etc…
In short, just build a module for libraries you need.

What about libs in the runtime?

Libraries in the runtime are in the LD_LIBRARY_PATH, so they should be automatically be found by a program. So no links should be needed there.

If you, for some reason, want to link to a file in the runtime, don’t. You have a bug in either your program or in Flatpak if it can’t find the runtime libraries.

But if you really, really need the link (the answer is still likely you don’t), then the runtime is mounted into the /usr prefix.

it doesn’t work because this proprietary software is miscompiled assuming that libxml2.so.2 is a standard library.

The runtime has libxml2.so.16 (different ABI)

So you only choice it to build an older version in the flatpak. Or recompile the software.

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