Snap do not run run with error "Could not load the Qt platform plugin “xcb” "

Hello! I have another problem with my snap(. It does not run with this error: " qt.qpa.plugin: Could not load the Qt platform plugin “xcb” in “/snap/master-pdf-editor-5/x1/lib/x86_64-linux-gnu/qt/plugins/platforms” even though it was found. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb."

However, libqxcb is installed. I try to run on Kubuntu 24.04 and Debian 12.

The problem is solved by building app with snapcraft version 7.5.8.

These infos may help: https://snapcraft.io/docs/qt5-kde-applications

I made a snap with that, it’s Chaotica2trial. You can install it then look at the .YAML into /snap/chaotica2trial/…

2 Likes

I am using snapcraft 8.7.4 to build my snap from a readymade binary created using pyinstaller containing pyqt. Yet I am getting the same error

fontrapak
qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin.
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: wayland-egl, minimalegl, offscreen, xcb, minimal, wayland, linuxfb, vkkhrdisplay, vnc.

======== Running on http://localhost:8002 ========
(Press CTRL+C to quit)
Aborted (core dumped)

I have the following details in my snapcraft.yaml

parts:
  fontrapak:
    stage-packages:
    - libgl1
    - libegl1
    - libxcb-cursor0
    plugin: dump
    source: . #  the pre-compiled binary is in the  bin directory in respect to snapcraft.yaml
    organize:
      fontrapak: bin/fontrapak  

icon: gui/fontrapak.svg
license: GPL-3.0+ 

apps:
  fontrapak:
    command: bin/fontrapak
    environment:
      QT_QPA_PLATFORM: xcb # Required for Qt applications in a snap
    plugs:
      - x11
      - unity7
      - opengl
      - network # if any network access is needed
      - home # if it needs access to user home directory
      - removable-media # if it needs access to removable media.
      - desktop
      - desktop-legacy
      - wayland # for wayland support

It worked when I added libxcb1 to staging

2 Likes

Thanks a lot! I will try with this step!

I also had to add extensions: [gnome] under apps: for file actions to work

It`s pity, but adding lib to stage part does not work…

After many debugging following configuration worked

parts:
  fontrapak:
    plugin: dump
    source: .
    organize:
      fontrapak: bin/fontrapak
    stage-packages:
      - libgl1
      - libegl1
      - libxcb-cursor0  # Add this explicitly
      - libxcb1
      - libxcb-render0
      - libxcb-shm0
      - libxcb-randr0
      - libxcb-xfixes0
      - libxkbcommon0
      - libqt5gui5        # Often needed for Qt applications
      - libqt5core5a      # Core Qt libraries
      - libqt5widgets5    # If your application uses widgets
      - libqt6gui6        # If your application uses Qt 6
      - libqt6core6       # Core Qt 6 libraries
      - libqt6widgets6    # If your application uses Qt 6 widgets
      - libstdc++6        # Standard C++ library (often a dependency)


plugs:
  shared-memory:
    private: true

apps:
  fontrapak:
    command: bin/fontrapak
    environment:
      QT_QPA_PLATFORM: xcb # Required for Qt applications in a snap (PyInstaller often uses Qt)
      QT_QPA_PLATFORM_PLUGIN_PATH: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/qt5/plugins/platforms:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/qt6/plugins/platforms # Explicitly set plugin path
      LD_LIBRARY_PATH: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET:$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/mesa  
    plugs:
      - x11
      - unity7
      - opengl
      - network  
      - home  
      - removable-media  
      - desktop
      - desktop-legacy
      - wayland
1 Like