Where are the downloaded libraries stored?

Aug 29, 2023
D

I used the python generator to create an install file for libclang which I included in my yaml file.
When my application tries to use ´libclang` though, I get:

“clang.cindex.LibclangError: libclang.so: cannot open shared object file: No such file or directory. To provide a path to libclang use Config.set_library_path() or Config.set_library_file().”

Does anyone know where libclang would be installed to, so that I can use Config.set_library_path() with that path?

This is my install file:

name: python3-libclang
buildsystem: simple
build-commands:
  - pip3 install --verbose --exists-action=i --no-index --find-links="file://${PWD}"
    --prefix=${FLATPAK_DEST} "libclang" --no-build-isolation
sources:
  - type: file
    url: https://files.pythonhosted.org/packages/c2/01/ec65dffc8c94bd8cafd359a76992f3212a239a80ead05522995c105432b8/libclang-16.0.6.tar.gz
    sha256: 4acdde39dfe410c877b4ccc0d4b57eb952100e4ee26bbdf6cfdb88e2033a7d31
J

It looks like the source distribution of this package doesn’t come with libclng, so you need to instal it separate

Update: It looks like org.freedesktop.Sdk.Extension.llvm16 contains libclang

D
Replying to #2

I am using the org.kde.Platform, does this also come with libclang?

D
Replying to #3

And if there is an extension to that as well, how would I add it to my mainfest file? Would I just exchange the “org.kde.Sdk” with “org.kde.Extension.llvm16”?

J

It’s a SDK extension, not a SDK. YOu need to add the following on top of your Manifest:

sdk-extensions:
  - org.freedesktop.Sdk.Extension.llvm16

and this to your modules section:

  - name: libclang
    buildsystem: simple
    build-commands:
      - mkdir -p $FLATPAK_DEST/lib
      - cp $(readlink -f /usr/lib/sdk/llvm16/lib/libclang.so) $FLATPAK_DEST/lib/libclang.so

libclang.so can be foudn after that in /app/lib

D
Replying to #5

I see, thanks. Is there anything similar for org.kde.Sdk though that I could use or can I use the freedesktop extensions on my org.kde.sdk as well?

J

As the KDE SDK is based on the Freedesktop SDK, you can use all Extensions that are made for the Freedesktop SDK

D
Replying to #8

I still get this error

FAILED: libs/mupdf/build/shared-release/libmupdfcpp.so /run/build/librum/libs/mupdf/build/shared-release/libmupdfcpp.so
cd /run/build/librum/libs/mupdf && ./scripts/mupdfwrap.py -d build/shared-release -b -j 0 m01
(+0.0s): parse.py:14:<module>: Warning, could not import clang: No module named 'clang'
(+0.1s): state.py:18:<module>: Warning: failed to import clang.cindex: e=ModuleNotFoundError("No module named 'clang'")
(+0.1s): state.py:18:<module>: We need Clang Python to build MuPDF python.
(+0.1s): state.py:18:<module>: Install with `pip install libclang` (typically inside a Python venv),
(+0.1s): state.py:18:<module>: or (OpenBSD only) `pkg_add py3-llvm.

This is my manifest:

app-id: com.librumreader.librum
runtime: org.kde.Platform
runtime-version: '6.5'
sdk-extensions:
- org.freedesktop.Sdk.Extension.llvm16
sdk: org.kde.Sdk
command: librum
finish-args:
- --share=ipc
- --share=network
- --socket=wayland
- --socket=fallback-x11
- --filesystem=home
- --device=dri
rename-desktop-file: librum.desktop
rename-icon: librum
modules:
- name: libclangInstall
buildsystem: simple
build-commands:
- mkdir -p $FLATPAK_DEST/lib
- cp $(readlink -f /usr/lib/sdk/llvm16/lib/libclang.so) $FLATPAK_DEST/lib/libclang.so
- name: librum
buildsystem: cmake-ninja
config-opts:
- -DCMAKE_BUILD_TYPE=Release
- -DBUILD_TESTS=Off
- -DNO_VENV=On
sources:
- type: git
url: https://github.com/Librum-Reader/Librum.git
commit: d62ee446dc3ad0b79c2598cc2132316902b46316
- name: install-files
buildsystem: simple
build-commands:
- install -Dm644 librum.desktop -t /app/share/applications
- install -Dm644 ../com.librumreader.librum.metainfo.xml -t /app/share/metainfo
- install -Dm644 src/logo.svg -t /app/share/icons/hicolor/scalable/apps/librum.svg

(The indentation got messed up by copy pasting)

D
Replying to #8

I see, thank you for elaborating. I am not sure about the above error though, since it says that libclang would not be installed.

J

It looks like you have the Python lib not in your Manifest

D
Replying to #11

What do you mean? The above file is my manifest

J

You said in your startpost that you want to instal pythpn3-libclang, but this is not in your Manifest

D
Replying to #13

I thought adding org.kde.Extension.llvm16 would remove the need for the extra python3-libclang.yaml file since it already installs it. Do I need both?

J

org.kde.Extension.llvm16 contains libclang itself, but not the Python bindings that you need

D
Replying to #15

I understand, so I need to import this file in my manifest?

name: python3-libclang
buildsystem: simple
build-commands:
- pip3 install --verbose --exists-action=i --no-index --find-links="file://${PWD}"
--prefix=${FLATPAK_DEST} "libclang" --no-build-isolation
- mkdir -p $FLATPAK_DEST/lib
- cp $(readlink -f /usr/lib/sdk/llvm16/lib/libclang.so) $FLATPAK_DEST/lib/libclang.so

sources:
- type: file
url: https://files.pythonhosted.org/packages/c2/01/ec65dffc8c94bd8cafd359a76992f3212a239a80ead05522995c105432b8/libclang-16.0.6.tar.gz
sha256: 4acdde39dfe410c877b4ccc0d4b57eb952100e4ee26bbdf6cfdb88e2033a7d31
D

It works! Thank you a lot, my project is now building.

D

One more thing @JakobDev.

My application expects the /resources/fonts folder from my git repo in $HOME/.var/app/com.librumreader.librum/data/Librum-Reader/Librum. How exactly can I reach that folder, I dont just want to mv ... $HOME/.var/app/com.librumreader.librum/data/Librum-Reader/Librum since I suppose that this will create problems on system wide installs?

H

it has the wrong expectations. This is not even a flatpak thing. The user directory is not for any application resource.