Qt Dependencies

When running snapcraft on Ubuntu 16.04 it pulls in the Qt libs which appear to be version 5.5, how do I pull in the later version like 5.10?

Otherwise deploying the app on a Ubuntu 16.04 clean install comes up with

QQmlApplicationEngine failed to load component
qrc:/dashboard.qml:1 module “QtQuick” version 2.9 is not installed

Thanks for any pointers

Cheers

Adam

Statically building the Qt app seems to work, but that seems a little bit of a fudge to me. So any advice on best practice or otherwise would be appreciated

Cheers

Adam

I’ve wrote a qt-build plugin for telegram which I actually should publish in some other repo which allows you to do multiple builds both with static and shared libraries.

See https://github.com/3v1n0/telegram-snap/blob/master/snap/plugins/x-qtbuilder.py
For an help in how to use it you can refer to the relative snapcraft.yaml of the very same repo.

I’ve other examples in this gist too: https://gist.github.com/3v1n0/0008e78d3903222baa8ba1379f8eba00

3 Likes

Looks like a great solution to me, thank you

I am getting the following error when running the app after using your plugin

qrc:/dashboard.qml:2 module “QtQuick.Controls” version 2.2 is not installed

I have the following submodules included

qt-submodules: [‘qtbase’, ‘qtimageformats’, ‘qtsvg’, ‘qtquickcontrols’, ‘qtquickcontrols2’, ‘qtvirtualkeyboard’, ‘qtwebsockets’, ‘qtdeclarative’]

Any ideas what I am doing wrong?

Mh, have you a log of the full snapcraft run and/or run find prime in the snap directory (after running at least snapcraft prime)?

Just run a snapcraft prime and I don’t see it including any libs, this is the element of the snapcraft.yaml that I have copied from your example

 qt:
    plugin: qtbuilder
    qt-version: 5.10.0
    qt-source-git: https://code.qt.io/qt/qt5.git
    qt-submodules: ['qtbase', 'qtimageformats', 'qtsvg', 'qtquickcontrols', 'qtquickcontrols2', 'qtvirtualkeyboard', 'qtwebsockets', 'qtdeclarative']
    environment:
      - CC: gcc-7
      - CXX: g++-7
      - QMAKE_CC: gcc-7
      - QMAKE_CXX: g++-7
    build-packages:
      - libasound2-dev
      - libdbusmenu-glib-dev
      - libffi-dev
      - liblzma-dev
      - libpulse-dev
      - libssl-dev
      - libx11-xcb-dev
      - libxcb-icccm4-dev
      - libxcb-image0-dev
      - libxcb-keysyms1-dev
      - libxcb-randr0-dev
      - libxcb-render-util0-dev
      - libxcb-sync-dev
      - libxcb-util0-dev
      - libxcb-xfixes0-dev
      - libxcb1-dev
      - libxrender-dev
    configflags:
      - -prefix
      - $SNAPCRAFT_STAGE
      - -release
      - -force-debug-info
      - -opensource
      - -confirm-license
      - -qt-zlib
      - -qt-libpng
      - -qt-libjpeg
      - -qt-freetype
      - -qt-harfbuzz
      - -qt-pcre
      - -qt-xcb
      - -qt-xkbcommon-x11
      - -no-opengl
      - -static
      - -dbus-runtime
      - -openssl-linked
      - -nomake
      - examples
      - -nomake
      - tests
    prime: [-./*]

Wasn’t aware of any logging in snapcraft so will figure out how to create/access a log and see if that helps

I can see the libs in the stage folder?

Thanks

Adam

That line tells snapcraft to ignore all the files in the part when building the prime directory. Basically everything from the qt part will be removed from the final snap.

Thanks, I have removed the prime line but still do not get the libs in the prime directory also tried with

prime:
  - ./*

But don’t see any libs at all.

What am I missing?

I don’t think the matcher is that smart (it could be). The default is * so if you remove the prime entry you will get all directories in there.

Thanks, removing the Prime section all together from the qt part still does not include the libs or anything in the stage folder?

Complete snapcraft.yaml below

name: testapp
version: 0.3.19
summary: testapp
description: testapp
grade: devel
confinement: strict

apps:
  testapp-daemon:
    command: bin/testapp-daemon
    daemon: simple
    plugs:
      - desktop
      - desktop-legacy
      - home
      - network
      - network-bind
      - network-manager
      - pulseaudio

parts:
  glue:
    plugin: dump
    source: glue

  testapp:
    plugin: qmake
    build-attributes:
     - no-system-libraries
    source: src/
    organize:
        opt/testapp/bin: bin
    prime:
      - bin/testapp
    after:
      - glue
      - qt

  qt:
    plugin: qtbuilder
    qt-version: 5.10.0
    qt-source-git: https://code.qt.io/qt/qt5.git
    qt-submodules: ['qtbase', 'qtimageformats', 'qtsvg', 'qtquickcontrols', 'qtquickcontrols2', 'qtvirtualkeyboard', 'qtwebsockets', 'qtdeclarative']
    environment:
      - CC: gcc-7
      - CXX: g++-7
      - QMAKE_CC: gcc-7
      - QMAKE_CXX: g++-7
    build-packages:
      - libasound2-dev
      - libdbusmenu-glib-dev
      - libffi-dev
      - liblzma-dev
      - libpulse-dev
      - libssl-dev
      - libx11-xcb-dev
      - libxcb-icccm4-dev
      - libxcb-image0-dev
      - libxcb-keysyms1-dev
      - libxcb-randr0-dev
      - libxcb-render-util0-dev
      - libxcb-sync-dev
      - libxcb-util0-dev
      - libxcb-xfixes0-dev
      - libxcb1-dev
      - libxrender-dev
    configflags:
      - -prefix
      - $SNAPCRAFT_STAGE
      - -release
      - -force-debug-info
      - -opensource
      - -confirm-license
      - -qt-zlib
      - -qt-libpng
      - -qt-libjpeg
      - -qt-freetype
      - -qt-harfbuzz
      - -qt-pcre
      - -qt-xcb
      - -qt-xkbcommon-x11
      - -no-opengl
      - -static
      - -dbus-runtime
      - -openssl-linked
      - -nomake
      - examples
      - -nomake
      - tests

Thanks for your help

Cheers

Adam

I am definitely not seeing this default behaviour none of the libs are copied in. Beginning to think it must be a bug?

None of the Qt part is included in the prime folder

1 Like

I have the same problem. Is there any solution?

I have not found a solution yet

I should have time next week to look into this, so if it is not solved by then, I will certainly be glad to help.

1 Like

I will be very grateful for your help.
Thank you

maybe you have found ways to solve this problem?

I think this is your problem.

Change that to /usr. Snapcraft will automatically rewrite it at install phase to prefix with $SNAPCRAFT_PART_INSTALL, which will then be staged to the equivalent place in $SNAPCRAFT_STAGE. You’re missing steps by putting the build directly into the stage directory before the stage snapcraft step.

I replaced what you advised, but now my application is not building.

g++ -Wl,-O1 -o hanoi-towers main.o backEnd.o hanoi-towers_plugin_import.o hanoi-towers_qml_plugin_import.o qrc_qml.o moc_backEnd.o   -L/root/Hanoi-Towers/parts/hanoi-tower/install/usr/lib -L/root/Hanoi-Towers/parts/hanoi-tower/install/usr/lib/x86_64-linux-gnu -L/usr/plugins/platforms -lqxcb -lQt5XcbQpa -lQt5ServiceSupport -lQt5ThemeSupport -lQt5EventDispatcherSupport -lQt5FontDatabaseSupport -lqtfreetype -lX11-xcb -lX11 -lXi -lSM -lICE -lxcb-static -lxcb -L/usr/plugins/imageformats -lqgif -lqicns -lqico -lqjpeg -lqtga -lqtiff -lqwbmp -lqwebp -L/usr/plugins/qmltooling -lqmldbg_debugger -lqmldbg_inspector -lqmldbg_local -lqmldbg_messages -lqmldbg_native -lqmldbg_nativedebugger -lqmldbg_profiler -lqmldbg_quickprofiler -lqmldbg_server -lQt5PacketProtocol -lqmldbg_tcp -L/usr/plugins/bearer -lqconnmanbearer -lqgenericbearer -lqnmbearer -lQt5DBus -L/usr/X11R6/lib64 -L/usr/qml/QtQuick.2 -lqtquick2plugin -L/usr/qml/QtQuick/Controls.2 -lqtquickcontrols2plugin -lQt5QuickControls2 -L/usr/qml/QtQuick/Templates.2 -lqtquicktemplates2plugin -lQt5QuickTemplates2 -L/usr/qml/QtQuick/Window.2 -lwindowplugin -L/usr/qml/QtQuick/Dialogs -ldialogplugin -L/usr/qml/Qt/labs/folderlistmodel -lqmlfolderlistmodelplugin -L/usr/qml/Qt/labs/settings -lqmlsettingsplugin -L/usr/qml/QtQuick/Dialogs/Private -ldialogsprivateplugin -L/usr/qml/QtQuick/Controls -lqtquickcontrolsplugin -L/usr/qml/QtQuick/PrivateWidgets -lwidgetsplugin -lQt5Widgets -L/usr/qml/QtQuick/Layouts -lqquicklayoutsplugin -L/usr/qml/QtQuick/Extras -lqtquickextrasplugin -lQt5Quick -lQt5Gui -lqtlibpng -lqtharfbuzz -lQt5Qml -lrt -lQt5Network -lssl -lcrypto -lQt5Core -lm -lqtpcre2 -ldl -lgthread-2.0 -lglib-2.0 -lpthread ```

/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libqtfreetype.a(ftgzip.o): In function `ft_gzip_file_done':
/root/Hanoi-Towers/parts/qt/build/qtbase/src/3rdparty/freetype/src/gzip/ftgzip.c:322: undefined reference to `z_inflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libqtfreetype.a(ftgzip.o): In function `ft_gzip_file_fill_output':
/root/Hanoi-Towers/parts/qt/build/qtbase/src/3rdparty/freetype/src/gzip/ftgzip.c:431: undefined reference to `z_inflate'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libqtfreetype.a(ftgzip.o): In function `ft_gzip_file_reset':
/root/Hanoi-Towers/parts/qt/build/qtbase/src/3rdparty/freetype/src/gzip/ftgzip.c:351: undefined reference to `z_inflateReset'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/libqtfreetype.a(ftgzip.o): In function `ft_gzip_file_init':
/root/Hanoi-Towers/parts/qt/build/qtbase/src/3rdparty/freetype/src/gzip/ftgzip.c:307: undefined reference to `z_inflateInit2_'

and more…

add zlib1g-dev to your build-packages for this part …