KDE Neon extension: libQt5Core.so.5: version `Qt_5.12' not found

I encountered an issue while switching the Krita snap to the KDE Neon extension.

The issue is that one of Krita’s runtime dependencies (stage-packages) pulls in Qt5 from the bionic repository while Krita is being built against the kde-frameworks-5-core18-sdk build snap. When Krita starts, it tries to use the Qt5 libraries from the bionic repository, which fails because that is not the Qt version it was built against.

/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/usr/bin/krita)

Full error message:

/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/usr/lib/x86_64-linux-gnu/libkritaui.so.18)
/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/usr/lib/x86_64-linux-gnu/libkritaimage.so.18)
/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/usr/lib/x86_64-linux-gnu/libkritawidgetutils.so.18)
/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/usr/lib/x86_64-linux-gnu/libkritaglobal.so.18)
/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/usr/lib/x86_64-linux-gnu/libkritaimpex.so.18)
/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/usr/lib/x86_64-linux-gnu/libkritacolor.so.18)
/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/usr/lib/x86_64-linux-gnu/libkritalibbrush.so.18)
/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/kf5/usr/lib/x86_64-linux-gnu/libQt5Multimedia.so.5)
/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/usr/lib/x86_64-linux-gnu/libkritawidgets.so.18)
/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/usr/lib/x86_64-linux-gnu/libkritaflake.so.18)
/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/usr/lib/x86_64-linux-gnu/libkritapsd.so.18)
/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/usr/lib/x86_64-linux-gnu/libkritapigment.so.18)
/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/usr/lib/x86_64-linux-gnu/libkritacommand.so.18)
/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/usr/lib/x86_64-linux-gnu/libkritametadata.so.18)
/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/usr/lib/x86_64-linux-gnu/libkritaodf.so.18)
/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/usr/lib/x86_64-linux-gnu/libkritastore.so.18)
/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/usr/lib/x86_64-linux-gnu/libkritaversion.so.18)
/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/usr/lib/x86_64-linux-gnu/libkritaplugin.so.18)
/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/usr/lib/x86_64-linux-gnu/libkritacolord.so.18)
/snap/krita/x1/usr/bin/krita: /snap/krita/x1/usr/lib/x86_64-linux-gnu/libQt5Core.so.5: version `Qt_5.12' not found (required by /snap/krita/x1/kf5/usr/lib/x86_64-linux-gnu/libQt5Concurrent.so.5)

I fixed the issue by explicitly excluding the Qt5 libraries from the bionic repo during stage:

    prime:
      - "-usr/share/fonts/*"
      # libquazip5-1 pulls in Qt5 from bionic as a dependency. We don't
      # want it in our snap, however, because we get a newer Qt5 from the
      # kde-kf5 platform snap.
      - "-usr/lib/x86_64-linux-gnu/libQt5*"
      - "-usr/lib/x86_64-linux-gnu/libqt5*"

Full snapcraft.yaml:

name: krita
version: 4.2.7.1
grade: stable
summary: Krita is the digital painting studio for artists
description: |
  Krita is a creative application for raster images. Whether you want to create
  from scratch or work with existing images, Krita is for you. You can work with
  photos or scanned images, or start with a blank slate. Krita supports most
  graphics tablets out of the box.

base: core18
confinement: strict

apps:
  krita:
    command: usr/bin/krita
    extensions:
      - kde-neon
    plugs: 
      - home
      - opengl
      - network
      - network-bind
      - removable-media
    desktop: usr/share/applications/org.kde.krita.desktop

layout:
  /usr/bin/ffmpeg:
    bind-file: $SNAP/usr/bin/ffmpeg

parts:
  krita:
    plugin: cmake
    configflags:
    - "-DCMAKE_INSTALL_PREFIX=/usr"
    - "-DCMAKE_BUILD_TYPE=Release"
    - "-DENABLE_TESTING=OFF"
    - "-DBUILD_TESTING=OFF"
    - "-DHIDE_SAFE_ASSERTS=OFF"
    - "-DKDE_SKIP_TEST_SETTINGS=ON"
    source: https://download.kde.org/stable/krita/4.2.7.1/krita-4.2.7.1.tar.xz
    # # Use these instead to build from the git source
    # source: https://anongit.kde.org/krita.git
    # source-type: git
    # source-branch: master
    override-stage: |
      # Stage the part
      snapcraftctl stage
      # Modify the .desktop file in the stage to point to where the icon will be in the installed snap
      sed -i 's|Icon=\(.*\)|Icon=${SNAP}/usr/share/icons/hicolor/1024x1024/apps/\1.png|' usr/share/applications/org.kde.krita.desktop
    build-snaps: [kde-frameworks-5-core18-sdk]
    build-packages:
      - libboost-dev
      - libboost-system-dev
      - libeigen3-dev
      - libfftw3-dev
      - libglew-dev
      - libgsf-1-dev
      - libgsl-dev
      - libjpeg-dev
      - libopencolorio-dev
      - libopenexr-dev
      - libopenimageio-dev
      - libquazip5-dev
      - libvc-dev
      - libx11-dev
      - libxi-dev
      - vc-dev

  runtime:
    plugin: nil
    stage-packages:
      - libboost-system1.65.1
      - libfftw3-double3
      - libgsl23
      - libilmbase12
      - libopencolorio1v5
      - libopenexr22
      - libquazip5-1
      - libxi6
      - zlib1g
      # Required for rendering animations
      - ffmpeg
      - libglu1-mesa
      - libslang2
    prime:
      - "-usr/share/fonts/*"
      # libquazip5-1 pulls in Qt5 from bionic as a dependency. We don't
      # want it in our snap, however, because we get a newer Qt5 from the
      # kde-kf5 platform snap.
      - "-usr/lib/x86_64-linux-gnu/libQt5*"
      - "-usr/lib/x86_64-linux-gnu/libqt5*"

I suspect many people will accidentally include qt5 as a dependency in their application. Is there any way to solve this issue in the extension itself; or warn the developer of this issue during a build?

I don’t think there is a real solution to this except for manual exclusion (which is in fact how the snaps built by neon do it, the get a blacklist from everything in the content snap injected by custom build tooling)

I’ve described the issue many moons ago:

1 Like

Interesting, thanks! Could you point me to the code for this build tooling? I’m interested to see how you generate the blacklist.