How to compile with QT5 specific version 5.14.2

I want to compile the application with 5.14.2 version of QT. What needs to be added in the snapcraft.yaml file.

Existing snapcraft.yaml file

name: qml-app
version: “1”
summary: Qt QML Application Example
description: Hello world Qt Quick application
grade: stable
confinement: strict
base: core18

apps:
qml-app:
environment:
LD_LIBRARY_PATH: /media/user1/Linux/new_qt5/Qt/5.14.2/gcc_64/lib
QT_QPA_PLATFORMTHEME: gtk3
QT_DEBUG_PLUGINS: 1
QML_IMPORT_TRACE: 1
QT_SELECT: snappy-qt5
command: desktop-launch Qt_qml_app_2
plugs: [unity7, home, waylan, opengl, gsettings]
parts:
qml-app:
source: .
plugin: qmake
#plugin: make
build-packages:
- qtdeclarative5-dev
- qtquickcontrols2-5-dev
- qttools5-dev
- libjsoncpp1
- qmlscene
- libqt5quick5
- libqt5quickwidgets5
- libqt5quick5-gles
- libqt5quickcontrols2-5
- libqt5quicktemplates2-5
- libqt5quickwidgets5-gles
- libqt5declarative5
- qtquickcontrols2-5-examples
- qtdeclarative5-window-plugin
- qtdeclarative5-qtquick2-plugin
- zlib1g-dev
stage-packages:
- libjsoncpp1
- libqt5qml5
- libqt5quick5
- libqt5quickcontrols2-5
- libqt5concurrent5
- libqt5core5a
- libqt5gui5
- qmlscene
- qml-module-qtquick-controls
- qml-module-qtquick-controls2
- qml-module-qtquick-templates2
- qml-module-qt-labs-platform
- qml-module-qtquick2
- qml-module-qtqml-models2
- qml-module-qt-labs-folderlistmodel
- qml-module-qtquick-xmllistmodel
- qml-module-qtwebchannel
- qml-module-qtwebengine
- qml-module-qtquick-dialogs
- qml-module-qtquick-extras
- qml-module-qtquick-layouts
- qml-module-qtquick-localstorage
- qml-module-qtquick-particles2
- qml-module-qtquick-privatewidgets
- qml-module-qtquick-scene2d
- qml-module-qtquick-scene3d
- qml-module-qtquick-virtualkeyboard
- qml-module-qtquick-window2
after: [desktop-qt5]

desktop-qt5:
source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
source-subdir: qt
plugin: make
make-parameters: [“FLAVOR=qt5”]
build-packages:
- build-essential
- qtbase5-dev
- dpkg-dev
stage-packages:
- libxkbcommon0
- ttf-ubuntu-font-family
- dmz-cursor-theme
- light-themes
- adwaita-icon-theme
- gnome-themes-standard
- shared-mime-info
- libqt5gui5
- libgdk-pixbuf2.0-0
- libqt5svg5 # for loading icon themes which are svg
- try: [appmenu-qt5] # not available on core18
- locales-all
- xdg-user-dirs
- fcitx-frontend-qt5
- qtwayland5

qt5-gtk-platform:
plugin: nil
stage-packages:
- qt5-gtk-platformtheme

qml-app:
plugin: dump
source: .
organize:
Qt_qml_app_2: bin/

plugs:
common-themes-snap/6235
gsettings:
gtk-3-themes:
interface: content
target: $SNAP/data-dir/themes
default-provider: gtk-common-themes
icon-themes:
interface: content
target: $SNAP/data-dir/icons
default-provider: gtk-common-themes
sound-themes:
interface: content
target: $SNAP/data-dir/sounds
default-provider: gtk-common-themes

make-parameters: [“FLAVOR=qt5”] takes only 2 flavours qt4 and qt5, how to use specific version of QT, i.e 5.14.2?

Unless compiled from source, snap uses the Qt distribution its targeting base ships. For example, core18 ships 5.9.5 while core20 ships 5.12.8.

The problem is, whether your application REALLY requires that specific Qt release.

Yes because it uses Qml which uses QtQuick version of 2.12 or 2.14. I am using ubuntu 18.04.

Note that the QML component is already available in Ubuntu 18.04, is there really a reason such version is not satisfiable?

Yes, the application is developed on 5.14.2 and I want to run that application in Kiosk mode on Ubuntu.

1 Like

Hi, there is no short way to do this right now traditional way would be compiling qt 5.14 by writing steps in your snapcraft.yaml but it will take a long time and resources.

So, instead of going this route, you can deploy your version yourself from your system install and dump it to your snap package.

I have packaged Qt 5.13 before and deployed it using qtlinuxdeploy. You can make a content snap of qt5.14 if you want to use it with your future applications, as I did with my qt513 snap.

1 Like

Hi, thanks for the suggestion. I tried with that , but it does not work on Ubuntu 18.04.
I get following error.

linuxdeployqt 6 (commit d41e234), build 724 built on 2020-07-31 15:51:47 UTC
ERROR: The host system is too new.
Please run on a system with a glibc version no newer than what comes with the oldest
currently still-supported mainstream distribution (xenial), which is glibc 2.23.
This is so that the resulting bundle will work on most still-supported Linux distributions.

while i bet there is a flag to override this check, if you do not find it, you could always remove base: core18 from your yaml … that should then make it switch automatically to base: core which is xenial based and uses the older glibc …

even if I simply run command “./linuxdeployqt-7-x86_64.AppImage” on terminal I get that error.
ERROR: The host system is too new.
Please run on a system with a glibc version no newer than what comes with the oldest
currently still-supported mainstream distribution (xenial), which is glibc 2.23.
This is so that the resulting bundle will work on most still-supported Linux distributions.

while running above command , do I need to pass any commandline parameters?

Hi, there is another way to achieve this. There is a PPA available for QT 5.14 on launchpad here. All you have to do is override your pull step and add PPA in your build container like this. Now you can install Qt 5.14 components like qt514base in stage-packages.

1 Like

If you are not able to use linuxdeployqt , The other nice alternative can be https://github.com/QuasarApp/CQtDeployer . This utility is also used to deploy Qt applications. There is a snap package available too.

1 Like

Thanks for the input. I am able to see the library path in the Makefile. But at the runtime it takes the default path of the Qt5.9.5. How do I ask the application to take 5.14.2/lib path instead of x86_64_linux_gnu/lib path. I kept 5.14.2/lib in /usr/share and bind it using layouts but could not succed. Also I tried to give 5.14.2/lib path in defailt.cf file at location /usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf but still it was taking qt5.9.5 path.

To set lib paths and other paths you can use qt.conf file in the bin directory like this or you can also use this desktop-launch script with modified paths.

Thanks a lot , cqtdeployer worked well with hello world app and I was able to run it with 5.14.2 library. I am now trying to run it as a daemon, following is my snapcraft.yaml.

name: cs-alto # you probably want to 'snapcraft register ’
base: core18 # 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: Control software example for packing with cqtdeployer # 79 char long summary
description: |
Control software example for packing with cqtdeployer

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

apps:
cs-alto:
environment:
__EGL_VENDOR_LIBRARY_DIRS: $SNAP/etc/glvnd/egl_vendor.d:$SNAP/usr/share/glvnd/egl_vendor.d
# XKB config
#XKB_CONFIG_ROOT: $SNAP/usr/share/X11/xkb
# Qt Platform to Wayland
QT_QPA_PLATFORM: wayland
#QT_QPA_PLATFORM: xcb
QTCHOOSER_NO_GLOBAL_DIR: 1
QT_SELECT: snappy-qt5
# Qt Modules
LD_LIBRARY_PATH: $SNAP/Qt/5.14.2/gcc_64/lib:$LD_LIBRARY_PATH
QT_PLUGIN_PATH: $SNAP/Qt/5.14.2/gcc_64/plugins
QML2_IMPORT_PATH: $QML2_IMPORT_PATH:$SNAP/Qt/5.14.2/gcc_64/qml
QT_QPA_PLATFORM_PLUGIN_PATH: $SNAP/Qt/5.14.2/gcc_64/plugins/platforms
# XDG Config
XDG_CONFIG_DIRS: $SNAP/etc/xdg:$SNAP/usr/xdg:$XDG_CONFIG_DIRS
XDG_DATA_DIRS: $SNAP/usr/share:$XDG_DATA_DIRS
# Font Config and themes
FONTCONFIG_PATH: $SNAP/etc/fonts/conf.d
FONTCONFIG_FILE: $SNAP/etc/fonts/fonts.conf
# Tell libGL where to find the drivers
LIBGL_DRIVERS_PATH: $SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/dri
command: desktop-launch $SNAP/qello.sh
plugs: [desktop, unity7, home, opengl, x11, wayland]
daemon:
daemon: simple
restart-condition: always
stop-timeout: “2m”
command: desktop-launch $SNAP/qello.sh
# daemon: simple
#restart-condition: always
#stop-timeout: “2m”
plugs: [desktop, unity7, home, opengl, x11, wayland]

parts:
cs-alto:
# See ‘snapcraft plugins’
plugin: dump
source: ./distro
after: [wrapper, libsgl]

wrapper:
plugin: dump
source: wrapper

libsgl:
plugin: nil
stage-packages:
# Here for the plugins-- they’re not linked in automatically.
- libx11-xcb1
- libglu1-mesa
- libxrender1
- libxi6
- libegl1-mesa
- fontconfig
- libgl1-mesa-dri
- libxkbcommon0
- ttf-ubuntu-font-family
- dmz-cursor-theme
- adwaita-icon-theme
- gnome-themes-standard
- shared-mime-info
- libgdk-pixbuf2.0-0
- libgtk2.0-0
- xdg-user-dirs
- libxrandr2
- libwayland-cursor0
- libwayland-egl1
- libpq5

It did not work as a demon. What I need to do to make it work as daemon.

i m following following link for running my app in kiosk mode on Ubuntu 18.04.

For following command from the above link, I am getting error.
a@a-Latitude-3480:~$ env -u WAYLAND_DISPLAY sudo mir-kiosk --wayland-host wayland-1

Error as follows.

2020-10-20 21:11:05.013825] mirserver: Found graphics driver: mir:wayland (version 2.1.0) Support priority: 256
No protocol specified
[2020-10-20 21:11:05.014131] mirserver: Found graphics driver: mir:x11 (version 2.1.0) Support priority: 0
[2020-10-20 21:11:05.014284] mirserver: Selected driver: mir:wayland (version 2.1.0)
ERROR: /build/mir-69uQDY/mir-2.1.0/src/server/graphics/default_configuration.cpp(136): Throw in function mir::DefaultServerConfiguration::the_graphics_platform()::<lambda()>
Dynamic exception type: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injectorstd::runtime_error >
std::exception::what: Exception while creating graphics platform
ERROR: /build/mir-69uQDY/mir-2.1.0/src/platforms/wayland/platform.cpp(40): Throw in function mir::graphics::wayland::Platform::Platform(wl_display*, const std::shared_ptrmir::graphics::DisplayReport&)
Dynamic exception type: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injectorstd::system_error >
std::exception::what: Failed to connect to wayland: EGL_SUCCESS (0x3000)