b
A note on Qt 5.9 cross-compile for Raspberry Pi 3 with Raspbian Stretch

The download link and the official directions to install Raspbian onto an SD card are described here.

At the time of this writing the cross-compilation of Qt for Raspberry Pi seems to be best described in https://wiki.qt.io/RaspberryPi2EGLFS.   To use this guide for version 3 of the Raspberry Pi board the device option in the ./configure command at step 10 needs to be changed to "-device  linux-rasp-pi3-g++" according to the directory listing under .../qtbase/mkspecs/devices/ of the Qt source code directory.   If the ./configure command results in errors, try adding a "-no-use-gold-linker" option to it as described here.

The version of Qt (or its separate modules) to be compiled may be downloaded over HTTP (i.e. Qt 5.9) or else using the git command in step 10 of the above compilation guide.   Using only the main version number 5.9 will clone the latest release available (5.9.7 at the time of this writing) though it may still be in Beta.  If you want to clone a sub-version (i.e. 5.9.6) using git instead of the manual download, the git command needs to be modified because subversions in the Qt repository are tags and not branches (the guide above does not get into the details on how the taged sub-versions are to be cloned).

In the past the suggested way to synchronize files between the cross-compilation computer and the Raspberry Pi was by mounting the Raspberry Pi SD card as described in this well written but otherwise outdated post which also provides more details on how to compile additional Qt modules after the compilation of Qtbase.   Please note that "qmake -r" may cause compilation errors for some modules and this latter outdated guide does not use the qmake recursive option (i.e. "qmake" instead of "qmake -r") for the compilation of additional modules.

The bytran application requires the following additional modules to be compiled: qtdeclarative,  qtquickcontrols2,  qtquickcontrols,   qtxmlpatterns (to enable QML, QtQuick, controls and dialogs), qtconnectivity (for bytran version 1.2 and above, to enable Bluetooth Low Energy, i.e. to access the SensorTag module), qtwebsockets, qtserialport (to enable remote connection and control of bytran), qtsensors, and qtsensehat (to access Sense HAT, see Sense HAT module instructions below).   To help determine which modules need to be compiled for your application please consult a chart in this post and the listing of Qt modules.

It is also possible to compile all Qt modules at once as suggested here, however in my experience the compilation of all modules was more likely to cause compilation errors like this if one attempts to compile a more recent version of Qt and/or use a newer model of the Raspberry Pi board than those the above guides where written for.   For the above reason it may be easier to compile the Qtbase module first and then only the modules needed to develop your application.   After the cross-compilation is complete, configure the Qt Creator.

If you are using the bytran binary archive containing the bytran executable and the Qt libs it depends on, you will need to install the libts-dev library before running bytran.   Additionally since the bytran archive was created based on these directions and the output of the windeployqt for bytran compiled under Windows, it is meant to be used with a fresh Raspbian installation.   As such if your Raspbian image already contains Qt libraries and bytran fails to start due to possible conflicts with the libraries supplied in the bytran binary archive, try running bytran using a "fresh" Raspbian SD image which does not have Qt libraries preinstalled.

Enabling Bluetooth

If you plan on using Bluetooth, the following libraries (libbluetooth-dev bluetooth blueman bluez libusb-dev libdbus-1-dev bluez-hcidump bluez-tools) need to be installed onto the Raspbian system after step 6 and before step 8 in the above guide as outlined in the following post.   These libraries must be installed onto the Raspberry Pi before the initial sync of the libs located on the Raspbian system (step 8 in the above guide) to the host cross-compilation computer.   As outlined in the above post, if you fail to install these libraries before you cross-compile, the Bluetooth will not be functional resulting in the "qt.bluetooth: Dummy backend running. Qt Bluetooth module is non-functional." message when you try to run your application.

Enabling Raspberry Pi's Sense HAT board

To be able to access the Sense HAT board several libraries need to be installed onto the Raspberry Pi image.   Although depending on the compilation approach these libraries may not be required for the Qt cross compilation for Sense HAT, it is recommended that they be installed onto the Raspberry Pi before the initial sync of the libs located on the Raspbian system (step 8 in the above guide) to the host cross-compilation computer.

www.bytran.org -|- 2017  
  Email:  bytran@bytran.org
© 2017 - 2022 Dzianis Pliutau