Note: Although I improvised a chroot to be able to fool around with it, I
would use pbuilder or sbuild to do the actual builds.

Helmut suggests pbuilder --host-arch or sbuild --host.

Doing it the non-Debian way

This guide in the meantime explains how
to set up a cross-compiling Qt toolchain in a rather dirty way, by recompiling
Qt pointing it at pieces of the Qt deployed on the Raspberry Pi.

Following that guide, replacing the CROSS_COMPILE value with
/usr/bin/arm-linux-gnueabihf- gave me a working qtbase, for which it is easy
to create a Kit for Qt Creator that works, and supports linking applications
with Debian development packages that do not use Qt.

However, at that point I need to recompile all dependencies that use Qt myself,
and I quickly got stuck at that monster of
QtWebEngine, whose sources embed the whole of
Chromium.

Having a Qt based development environment in which I need to become the
maintainer for the whole Qt toolchain is not a product I can offer to a
customer. Cross compiling qmake based packages on stretch is not currently
supported, so at the moment I had to suggest
to postpone all plans for total world domination for at least two years.

Cross-building Debian

helmut> enrico: yes, cross building is painful. we have ~26000 source
packages. of those, ~13000 build arch-dep packages. of those, ~6000 have
cross-satisfiable build-depends. of those, I tried cross building ~2300. of
those 1300 cross built. so we are at about 10% working.

helmut> enrico: plus there are some 607 source packages affected by some 326 bugs with patches.

helmut> enrico: gogo nmu them

helmut> enrico: I've filed some 1000 bugs (most of them with patches) now. around 600 are fixed :)

He is doing it mostly alone, and I would like people not to be alone when they
do a lot of work in Debian, so…

Join Helmut in the effort of making Debian cross-buildable!

Build any Debian package for any device right from the comfort of your own work computer!

Have a single development environment seamlessly spanning architecture
boundaries, with the power of all that there is in Debian!

qemu-user-static

Helmut also suggested to use qemu-user-static to make the host system able to
run binaries compiled for the target system, so that even if a
non-cross-compiling Qt build tries to run moc and friends in their target
architecture version, they would transparently succeed.

At that point, it would just be a matter of replacing compiler paths to point
to the native cross-compiling gcc, and the build would not be slowed down by
much.

Fixing bug #781226 would help in
making it possible to configure a multiarch version of qmake as the qmake used
for cross compiling.

I have not had a chance of trying to cross-build in this way yet.

In the meantime...

Having qtcreator able to work on an amd64 devel machine and deploy/test/debug
remotely on an arm target machine, where both machine run debian stable and
have libraries in sync, would be a great thing to have even though packages do
not cross-build yet.

Helmut summarised the situation on IRC:

svuorela and others repeat that Qt upstream is not compatible with Debian's multiarch thinking, in that Qt
upstream insists on having one toolchain for each pair of architectures,
whereas the Debian way tends to be to make packages generic and split stuff
such that it can be mixed and matched.

An example being that you need to run qmake (thus you need qmake for the
build architecture), but qmake also embeds the relevant paths and you need to
query it for them (so you need qmake for the host architecture)

Either you run it through qemu, or you have a particular cross qmake for your
build/host pair, or you fix qt upstream to stop this madness

Building qmake in Debian for each host-target pair, even just limited to
released architectures, would mean building Qt 100 times, and that's not going
to scale.

I wonder:

can I have a qmake-$ARCH binary that can build a source using locally
installed multiarch Qt libraries, do I need to recompile and ship the whole
of Qt, or just qmake?

is there a recipe for building a cross-building Qt environment that would be
able use Debian development libraries installed the normal multiarch way?