Enrico Zini: Qt5 custom build for amd64
This is part of a series of posts on compiling a custom version of Qt5 in order
to develop for both amd64 and a Raspberry Pi.
First step, build Qt5 5.15 packages for amd64.
To prevent conflicting with Debian Qt packages, we'll install everything in
/opt.
We can install
If needed, install the Qt license:
Install build dependencies
You can use
Alternatively, you can create an installable
Package build
The package is built by
In
Building software using custom Qt
One just needs to export
Or:
If switching from one Qt to another, it is possible that the makefiles created
by one qmake are not working well with the other. In that case, one can just
remove them and regenerate them.
qtchooser configuration files to allow developers to easily
switch between Debian's standard Qt version or the custom version, at will.
The resulting packaging is at https://github.com/Truelite/qt5custom.
Set up sources
Open the source tarball, and add the amd64 packaging:
tar axf qt-everywhere-src-5.15.0.tar.xz cp -a debian-amd64 qt-everywhere-src-5.15.0/debian
cp qt-license.txt ~/.qt-license
apt build-dep to install dependencies manually:
cd qt-everywhere-src-5.15.0
apt build-dep .
.deb metapackage that depends on
the build dependencies:
apt install devscripts mk-build-deps debian-amd64/control apt -f install qt-everywhere-src-build-deps_5.15.0-1_amd64.deb
debian/rules base on the excellent work done by
Debian Qt5 maintainers
After installing the build dependencies, you can build like this:
cd qt-everywhere-src-5.15.0
fakeroot debian/rules binary
debian/rules you can configure NUMJOBS with the number of available
CPUs in the machine, to have parallel builds.
Build output
Building sources generates 4 packages:
libqt5custom: the runtime environmentlibqt5custom-dbgsym: debugging symbols for the runtime environmentqtbase5custom-dev: the build environmentqtbase5custom-dev-dbgsym: debugging symbols for the build environment
qtbase5custom-dev and libqt5custom are needed for development; only
libqt5custom is needed to run build programs.
Using custom Qt for amd64
These Qt custom packages install their content in /opt, and are
coninstallable with the version of Qt distributed in Debian.
One needs to be careful not to create programs that link, either directly or
indirectly, with both the Debian Qt and the custom Qt, because the in memory
layout of objects could be different and incompatible, causing unexpected
results.
Selecting which Qt version to use: qtchooser
These Qt custom packages integrate with qtchooser to select the version of Qt
to use at compile time.
qtchooser --list-versions lists available versions. One can choose what to
use by exporting QT_SELECT:
# apt install qtchooser qt5-qmake qt5-default $ qtchooser --list-versions 4 5 qt4-x86_64-linux-gnu qt4 qt5-x86_64-linux-gnu qt5 qt5custom-x86_64-linux-gnu qt5custom $ qmake --version QMake version 3.1 Using Qt version 5.11.3 in /usr/lib/x86_64-linux-gnu $ export QT_SELECT=qt5custom $ qmake --version QMake version 3.1 Using Qt version 5.15.0 in /opt/qt5custom/lib
QT_SELECT=qt5custom in the environment, then proceed
to build normally:
export QT_SELECT=qt5custom fakeroot ./debian/rules clean binary
export QT_SELECT=qt5custom qmake file.pro