Search code examples
qtcross-compilingraspberry-pi3

QT, understanding cross-compiling for Raspberry PI3


I'm trying to understand how to cross-compile for a Raspberry PI3.

First, let me check if I understood correctly the meaning of the cross-compiling: is it to compile for a hardware that is different from the machine I'm building my application? This means, building for example a linux application from a windows system?

Second, all the tutorials I found required the building of QT for the target platform. Is this because to build a QT application I need the target-hardware-specific-built-version of QT libraries? Why there are no pre-built versions?

Third, I don't understand why a raspberry image is required in all the tutorials I could find.

Those are some of the tutorials I found, I found really strange that such a long setup is needed to cross-compile an application and I'm just wondering if what I'm trying to do (compile from a Linux machine a raspberry-pi3 QT application) is what those articles are really describing.

Tutorial 1, Tutorial 2, QT official embedded device page


Solution

  • You are correct, cross-compiling is building on one type of hardware (Host) to run on a different type of hardware (Target).

    If you are willing to go for a commercial version of Qt, Qt will provided a turnkey solution (Boot to Qt) for developing on a specific Raspberry Pi. By turn-key, I mean they have all the target tools for cross compiling and the correctly built libraries for the target, etc. It's not cheap, and probably not the way to go for the hobbyist.

    If you go with the open source (free) version of Qt, you will need to do most of the setup work yourself. The reason you are having a hard time finding everything built for you are mostly related to two things: The size of the distribution, and what you are building for what (i.e. which Qt version for which Raspberry Pi and which Raspberry Pi Linux version and which drivers, etc.).

    The Raspberry Pi image is needed as you need the correct libraries to build Qt against. The cross-compilation tools need to link against the target (Raspberry Pi) images.

    Yes, it is a long process to setup a Qt cross compilation environment, but it only needs to be done when once for each Qt version. Once you have setup the environment, building and deploying a Qt application on the target Raspberry Pi is really quite fast and easy.