Unable to build X11-based app | Undefined reference

Hello everyone.

I’m trying to build my own Qt4 app based on X11 to run it on Ubuntu Core using ubuntu-frame. Like in the tutorial. But during snap crafting I always get an error on the snapcraftctl build step.

Here is my log:

/root/parts/qt4-test/install/usr/lib/x86_64-linux-gnu/libpng16.so.16: undefined reference to `pow@GLIBC_2.29'
collect2: error: ld returned 1 exit status
Makefile:141: recipe for target 'qt4-test' failed
make: *** [qt4-test] Error 1
Failed to run 'make -j2' for 'qt4-test': Exited with code 2.
Verify that the part is using the correct parameters and try again.

And this is how my .yaml file looks like:

name: qt4-test
base: core18
version: '1'
summary: Qt4 test snap
description: |
  Qt4 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

    daemon: simple
    restart-condition: always
      - env-setup
    command: $SNAP/usr/local/bin/x11_kiosk_launch $SNAP/opt/qt4-test/bin/qt4-test
      - wayland # for Mir
      - kde-neon
    plugin: qmake
    source: src/
      - mesa-utils
    after: [qt4]
    stage-snaps: [mir-kiosk-x11]
    source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
    source-subdir: qt
    plugin: make
    make-parameters: ["FLAVOR=qt4"]
      - libqt4-dev
      - dpkg-dev
      - libxkbcommon0
      - ttf-ubuntu-font-family
      - dmz-cursor-theme
      - light-themes
      - adwaita-icon-theme
      - gnome-themes-standard
      - shared-mime-info
      - libqtgui4
      - libgdk-pixbuf2.0-0
      - libqt4-svg # for loading icon themes which are svg
      - appmenu-qt
      - locales-all
      - sni-qt

    bind: $SNAP/usr/share/X11
    symlink: $SNAP/usr/bin/xkbcomp

I suppose that I need to include or exclude some libraries. But I can’t understand which one.

I have already tried to add libpng16-16 to stage-packages. But it didn’t help.

Does anybody know how to solve that problem?

Thanks in advance. I will appreciate any help.

It looks as though your build is failing the qt4-test part. Since that part is using qmake I would expect to see any build dependencies listed there as build-packages, that might be the cause of the link error you see. (I would guess libc6-dev is missing.)

After resolving your build problems I think you will see further problems:

  1. The mir-kiosk-x11 snap is core20 based and staging that in this core18 snap will likely lead to runtime errors.

  2. As you are intending to create a snap for Ubuntu Core you are probably better without snapcraft-desktop-helpers, that is an obsolete approach to desktop integration (and there is no desktop on Core).

Thank you for your response. I will try to add libc6-dev.

I used core20. But I got problems with fetching Qt4 packages (I think because they are not supported by core20).

Where could I find information about building snaps without snapcraft-desktop-helpers? Or should I just remove qt4 part?

Yes, the most recent series to have qt4 is 18.04, so it isn’t available from the default core20 archive. (I don’t know if there’s a PPA somewhere.)

I don’t know where you found information about building snaps with snapcraft-desktop-helpers. That has been superseded by various extensions for several years. (Although the extensions can also hit problems on Core.)

Apart from the tutorial you’re following (which doesn’t use snapcraft-desktop-helpers) the best information for creating graphics for Core is:

but that is also based on core20 (which, as you note, doesn’t support Qt4).

To use core18 and Qt4 is going to need work: backporting the functionality of mir-kiosk-x11 and mir-graphics-core20.

If you can find (or provide) Qt4 support for 20.04 via a PPA, then that will be easier.

(I realise moving code to Qt5 can be a lot of work, but it’s been ten years now!)