Skip to content

Bundling Qt apps

probonopd edited this page Oct 23, 2021 · 24 revisions

QStandardPaths issue

If an application is relying on QStringList QStandardPaths::standardLocations(QStandardPaths::AppDataLocation); the XDG_DATA_DIRS environment variable must be exported to .../share/ in the AppDir by AppRun. (Note that linuxdeployqt does not use an AppRun file, just a symlink, and as a result this does not work there.)

As a fallback, you can use QString QCoreApplication::applicationDirPath() instead and construct a relative path to ../share/kaidan/images/ from there.

For an example, see: https://github.com/KaidanIM/Kaidan/commit/da38011b55a1aa5d17764647ecd699deb4be437f

As a result, it should work both in normal installations and in relocatable installations such as AppImages.

Theming for Gtk systems

Be sure to build

plugins/styles/libqgtk2style.so
plugins/platformthemes/libqgtk2.so

e.g., like this:

apt-get update
apt-get -y install libgtk2.0-dev
git clone http://code.qt.io/qt/qtstyleplugins.git
cd qtstyleplugins
qmake # be sure to use the one from the Qt installation you are using for the application
make -j$(nproc)
sudo make install 
cd -

Theming for Gnome systems

If you want a Gnome look and feel, then maybe the actively developed

https://github.com/FedoraQt/QGnomePlatform

can be used.

linuxdeployqt

The Linux Deployment Tool for Qt, linuxdeployqt, takes an application as input and makes it self-contained by copying in the Qt libraries and plugins that the application uses into a bundle. This can optionally be put into an AppImage.

The rest of this page may be outdated.

Other (legacy information)

This section of this page may be outdated.

Bundle Travis CI build artifacts as AppImage

See this patch for how existing continuous builds on Travis CI can be turned into AppImages with ease. https://github.com/cpvrlab/ImagePlay/pull/93/files?diff=unified

qt.conf

Using qt.conf you can change the paths Qt uses, e.g., for loading its plugins. http://doc.qt.io/qt-5/qt-conf.html

Use upstream Qt binaries

Download Qt from http://download.qt.io/online/qtsdkrepository - apparently it is built in a distro-agnostic way, which is good. This can be used both for building (e.g., on travis-ci) and for bundling.

You would think that there is an easy way to install Qt binaries from upstream without the need for a GUI, but so far I have not found an easy way yet. Hence the somewhat harder way below.

Assuming that we want to unpack Qt to /home/me/5.5, we can use:

# Install CMake 3.2.2 and Qt 5.4.1 # https://github.com/vlc-qt/examples/blob/master/tools/ci/linux/install.sh
wget http://www.cmake.org/files/v3.2/cmake-3.2.2-Linux-x86_64.tar.gz
tar xf cmake-3.2.2-Linux-x86_64.tar.gz
wget http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_55/qt.55.gcc_64/5.5.0-2qt5_essentials.7z
wget http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_55/qt.55.gcc_64/5.5.0-2icu-linux-g++-Rhel6.6-x64.7z
wget http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_55/qt.55.gcc_64/5.5.0-2qt5_addons.7z
7z x *_essentials.7z > /dev/null
7z x *icu-linux-*.7z > /dev/null
7z x *_addons.7z > /dev/null
export PATH=$PWD/cmake-3.2.2-Linux-x86_64/bin/:$PWD/5.5/gcc_64/bin/:$PATH

export LD_LIBRARY_PATH=$PWD/5.5/gcc_64/lib

# This is a super cool trick to bundle all libraries that are not part of the build host base system
apt-get install pax-utils

# ALL libraries needed by this binary
lddtree 5.5/gcc_64/bin/designer | grep "=>" | awk '{print $3}'

# All libraries needed by this binary that are NOT part of /lib of the build system
lddtree 5.5/gcc_64/bin/designer | grep "=>" | awk '{print $3}' | grep -ve "^/lib"

# As an alterative to pax-utils' lddtree, you could try ldd-recursive:
# http://sourceforge.net/projects/recursive-ldd/
# This sometimes returns more dependencies than lddtree
ldd-recursive -uniq 5.5/gcc_64/bin/designer | grep -ve "^/lib"

Direct Qt binary download links

############################################################################################################
# http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_54/Updates.xml
############################################################################################################

# qt.54.gcc_64
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_54/qt.54.gcc_64/5.4.2-0qt5_essentials.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_54/qt.54.gcc_64/5.4.2-0qt5_addons.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_54/qt.54.gcc_64/5.4.2-0icu_53_1_ubuntu_11_10_64.7z

# qt.54.qtwebengine.gcc_64
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_54/qt.54.qtwebengine.gcc_64/5.4.2-0qt5_qtwebengine.7z


############################################################################################################
# http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_55/Updates.xml
############################################################################################################

# qt.55.gcc_64
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_55/qt.55.gcc_64/5.5.1-0qt5_essentials.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_55/qt.55.gcc_64/5.5.1-0qt5_addons.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_55/qt.55.gcc_64/5.5.1-0icu-linux-g++-Rhel6.6-x64.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_55/qt.55.gcc_64/5.5.1-0qt5_qtpositioning.7z

# qt.55.qt3d.gcc_64
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_55/qt.55.qt3d.gcc_64/5.5.1-0qt5_qt3d.7z

# qt.55.qtcanvas3d.gcc_64
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_55/qt.55.qtcanvas3d.gcc_64/5.5.1-0qt5_qtcanvas3d.7z

# qt.55.qtlocation.gcc_64
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_55/qt.55.qtlocation.gcc_64/5.5.1-0qt5_qtlocation.7z

# qt.55.qtquick1.gcc_64
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_55/qt.55.qtquick1.gcc_64/5.5.1-0qt5_qtquick1.7z

# qt.55.qtquickcontrols.gcc_64
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_55/qt.55.qtquickcontrols.gcc_64/5.5.1-0qt5_qtquickcontrols.7z

# qt.55.qtscript.gcc_64
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_55/qt.55.qtscript.gcc_64/5.5.1-0qt5_qtscript.7z

# qt.55.qtwebengine.gcc_64
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_55/qt.55.qtwebengine.gcc_64/5.5.1-0qt5_qtwebengine.7z


############################################################################################################
# http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/Updates.xml
############################################################################################################

# qt.56.gcc_64
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.gcc_64/5.6.0-1qtbase-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.gcc_64/5.6.0-1qtconnectivity-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.gcc_64/5.6.0-1qtx11extras-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.gcc_64/5.6.0-1qtwebchannel-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.gcc_64/5.6.0-1qtmultimedia-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.gcc_64/5.6.0-1qttranslations-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.gcc_64/5.6.0-1qtgraphicaleffects-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.gcc_64/5.6.0-1qtsvg-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.gcc_64/5.6.0-1qtdeclarative-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.gcc_64/5.6.0-1qtwebsockets-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.gcc_64/5.6.0-1qtimageformats-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.gcc_64/5.6.0-1qttools-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.gcc_64/5.6.0-1qtxmlpatterns-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.gcc_64/5.6.0-1qtsensors-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.gcc_64/5.6.0-1qtpositioning-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.gcc_64/5.6.0-1qtserialport-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.gcc_64/5.6.0-1icu-linux-Rhel6.6-x64.7z

# qt.56.qt3d.gcc_64
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.qt3d.gcc_64/5.6.0-1qt3d-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z

# qt.56.qtcanvas3d.gcc_64
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.qtcanvas3d.gcc_64/5.6.0-1qtcanvas3d-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z

# qt.56.qtlocation.gcc_64
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.qtlocation.gcc_64/5.6.0-1qtlocation-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z

# qt.56.qtquickcontrols.gcc_64
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.qtquickcontrols.gcc_64/5.6.0-1qtquickcontrols-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z

# qt.56.qtquickcontrols2.gcc_64
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.qtquickcontrols2.gcc_64/5.6.0-1qtquickcontrols2-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z

# qt.56.qtscript.gcc_64
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.qtscript.gcc_64/5.6.0-1qtscript-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z

# qt.56.qtserialbus.gcc_64
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.qtserialbus.gcc_64/5.6.0-1qtserialbus-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z

# qt.56.qtwebengine.gcc_64
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.qtwebengine.gcc_64/5.6.0-1qtwebengine-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z

# qt.56.qtwebview.gcc_64
http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_56/qt.56.qtwebview.gcc_64/5.6.0-1qtwebview-Linux-RHEL_6_6-GCC-Linux-RHEL_6_6-X86_64.7z

These links were generated with the following Python script:

#!/usr/bin/python

import xmltodict # sudo apt install python-xmltodict
import urllib2, os

def do(version):
    url = "http://download.qt.io/online/qtsdkrepository/linux_x64/desktop/qt5_" + str(version) + "/Updates.xml"

    print("")
    print("############################################################################################################")
    print("# " + url)
    print("############################################################################################################")
    print("")

    response = urllib2.urlopen(url)
    xml = response.read()
    data = xmltodict.parse(xml)

    for item in data["Updates"]["PackageUpdate"]:
        if(item["DownloadableArchives"]):
            print "# " + item["Name"]
            for archive in item["DownloadableArchives"].split(", "):
                print(os.path.join(os.path.dirname(url), item["Name"], item["Version"] + archive ))
            print ""

if(__name__ == "__main__"):
    for version in (54 ,55, 56):
        do(version=version)