Snapcraft pack Qt6 for Ubuntu Core

Hello everybody, i’m a complete beginner on Ubuntu and Linux. I try to turn my app made with Qt6 (widgets only for now), compile it with CMake and turn it to a Snap that will run on Ubuntu Core (arm64) using Wayland and Ubuntu-Frame.

The CMake part working, and Snapcraft create the snap correctly. But impossible to use it with Ubuntu-frame and Frame-it.

I use the tutorial at those address :

Ubuntu Version :
Ubuntu 24.04.3 LTS - AMD64

Desktop Environment :
GNOME : 46
Display : X11
Core : Linux 6.14.0-32-generic

Here is my snapcraft.yaml. I used the sample of iot-example-graphical-snap and mixed what i tryied before (and seems working) with this project.

name: homecontroller # you probably want to 'snapcraft register <name>'
base: core24 # the base snap is the execution environment for this snap
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: Test snap # 79 char long summary
description: |
  Mon test Snap

grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots

apps:
  homecontroller: # +++++++++++++++++++++++++++++++ 1
    command-chain: &_command-chain
      - bin/gpu-2404-wrapper
      - bin/wayland-launch
    command: &_command bin/homecontroller #usr/local/bin/homecontroller
    plugs: &_plugs
      - opengl
      - wayland
      - x11
      - desktop
      - desktop-legacy
    # ======== environment ========
    environment: &_environment
      XDG_DATA_HOME: $SNAP_USER_DATA
      XDG_DATA_DIRS: $SNAP/usr/share
  daemon: # +++++++++++++++++++++++++++++++++++++++++ 2
    daemon: simple
    restart-delay: 3s
    restart-condition: always
    command-chain: *_command-chain
    command: *_command
    plugs: *_plugs
    environment: *_environment
      
# ============ PLUGS ============
# This is one of four snippets that relate to providing the userspace graphics needed by your application.
# You can treat this as "magic" so long as you don't need to make changes.
# On the Mir website there's a lot more detail on [the gpu-2404 Snap interface](https://mir-server.io/docs/the-gpu-2404-snap-interface) and it's use.
plugs:
  gpu-2404:
    interface: content
    target: $SNAP/gpu-2404
    default-provider: mesa-2404
      
# ============ ENVIRONMENT ============
environment:
  # Other, generally useful environment settings...
  # XDG config
  XDG_CACHE_HOME:  $SNAP_USER_COMMON/.cache
  XDG_CONFIG_HOME: $SNAP_USER_DATA/.config
  XDG_CONFIG_DIRS: $SNAP/etc/xdg
  XDG_DATA_DIRS:   $SNAP/usr/local/share:$SNAP/usr/share
  # XKB config
  XKB_CONFIG_ROOT: $SNAP/usr/share/X11/xkb #SNAP ?
  # QT QPA PLATFORM
  QT_QPA_PLATFORM: wayland
  QT_QPA_PLATFORM_PLUGIN_PATH: ${SNAP}/usr/lib/x86_64-linux-gnu/qt6/plugins/platforms
      
# ============ Layout ============
layout:
  /usr/share/libdrm:
    bind: $SNAP/gpu-2404/libdrm
  /usr/share/drirc.d:
    symlink: $SNAP/gpu-2404/drirc.d
  # Other, generally useful paths
  /usr/share/fonts:
    bind: $SNAP/usr/share/fonts
  /usr/share/icons:
    bind: $SNAP/usr/share/icons
  /usr/share/sounds:
    bind: $SNAP/usr/share/sounds
  /etc/fonts:
    bind: $SNAP/etc/fonts
  # GTK
  /usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/gdk-pixbuf-2.0:
    bind: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/gdk-pixbuf-2.0
  /usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/gtk-3.0:
    bind: $SNAP/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/gtk-3.0
  /usr/share/mime:
    bind: $SNAP/usr/share/mime
  /etc/gtk-3.0:
    bind: $SNAP/etc/gtk-3.0

# ============ Details of parts ============
parts:
  homecontroller:
    # See 'snapcraft plugins'
    plugin: cmake
    source: ./src
    cmake-parameters:
      - -DCMAKE_INSTALL_PREFIX=/
      - -DCMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu/cmake
      - -DCMAKE_BUILD_TYPE=Release
    build-packages:
      - build-essential # try
      - cmake
      - g++
      - qt6-base-dev
      - qt6-tools-dev
      - qt6-tools-dev-tools # try start
      - qt6-wayland-dev
      - libwayland-dev
      - libgles2-mesa-dev
      - libxkbcommon-dev # try end
    stage-packages:
      - qt6-base-dev
      - libqt6core6 # try start
      - libqt6widgets6
      - libqt6gui6
      - libqt6network6
      - libqt6waylandclient6
      - libqt6waylandcompositor6
      - libqt6gui6
      - libwayland-egl1-mesa
      - libwayland-server0
      - libgles2
      - libwayland-client0
      - libxkbcommon0
      - qt6-wayland # try end
      
  # Import
  gsettings+pixbuf+immodules:
    plugin: nil
    build-packages:
      - libgdk-pixbuf2.0-0
      - librsvg2-common
      - shared-mime-info
      - libgtk-3-0
    override-build: |
      craftctl default
      # Update mime database
      update-mime-database ${CRAFT_PART_INSTALL}/usr/share/mime
      # build immodules cache
      mkdir -p ${CRAFT_PART_INSTALL}/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/gtk-3.0/3.0.0/
      /usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/libgtk-3-0t64/gtk-query-immodules-3.0 > ${CRAFT_PART_INSTALL}/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/gtk-3.0/3.0.0/immodules.cache
    stage-packages:
      - librsvg2-common
      - gsettings-desktop-schemas
      - libglib2.0-bin
    override-prime: |
      craftctl default
      # Compile the gsettings schemas
      /usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/glib-2.0/glib-compile-schemas "$CRAFT_PRIME/usr/share/glib-2.0/schemas"
      # Index the pixbuf loaders
      LOADERS_PATH=$(echo ${CRAFT_PRIME}/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_FOR}/gdk-pixbuf-2.0/*/loaders)
      QUERY_LOADERS=/usr/lib/${CRAFT_ARCH_TRIPLET_BUILD_ON}/gdk-pixbuf-2.0/gdk-pixbuf-query-loaders
      GDK_PIXBUF_MODULEDIR=${LOADERS_PATH} ${QUERY_LOADERS} > ${LOADERS_PATH}/../loaders.cache
      sed s!$CRAFT_PRIME!!g --in-place ${LOADERS_PATH}/../loaders.cache

  # Some utility scripts for setting up the Wayland environment
  setup:
    plugin: dump
    source: wayland-launch
    override-build: |
      # The plugs needed to run Wayland. (wayland-launch checks them, setup.sh connects them)
      chmod 755 $CRAFT_PART_BUILD/bin/wayland-launch # Try to give permission to execute
      chmod 755 $CRAFT_PART_BUILD/bin/setup.sh # Try to give permission to execute
      # You may add further plugs here if you want these options
      PLUGS="opengl wayland gpu-2404"
      sed --in-place "s/%PLUGS%/$PLUGS/g" $CRAFT_PART_BUILD/bin/wayland-launch
      sed --in-place "s/%PLUGS%/$PLUGS/g" $CRAFT_PART_BUILD/bin/setup.sh
      craftctl default
    stage-packages:
      - inotify-tools

  gpu-2404:
    after:
      # Your application packaging
      - gsettings+pixbuf+immodules
      - setup
    source: https://github.com/canonical/gpu-snap.git
    plugin: dump
    override-prime: |
      craftctl default
      ${CRAFT_PART_SRC}/bin/gpu-2404-cleanup mesa-2404
      cd "$CRAFT_PRIME/usr/share/"
      rm -rf bug drirc.d glvnd libdrm lintian man
      rm -rf applications apport bash-completion dbus-1 doc-base doc gtk-doc\
             help pkgconfig libthai metainfo themes thumbnailers xml
    prime:
      - bin/gpu-2404-wrapper

platforms:
  amd64:
  armhf:
  arm64:

My project structure looks like this :
HomeController
⊦ snap
| ∟snapcraft.yaml
⊦ src
| ⊦ main.cpp
| ∟CMakeLists.txt
∟wayland-launch
∟bin
⊦ setup.sh
∟wayland-launch

Is anybody can help to understand what I make wrong ? :pray:

Thank you for reading

This post needs to be directed to https://forum.snapcraft.io. Snap is not an Ubuntu project, despite being a Canonical product. Please post this question there.

Thank you.

1 Like