Skip to content
Guillaume Lazar edited this page Aug 14, 2018 · 4 revisions

What is QtRpi?

QtRpi is a complete bundle to simplify the cross-compilation of Qt applications on the Raspberry Pi. This bundle is composed of:

  • A preconfigured Qt version for your computer

  • Precompiled Qt binaries for your Raspberry Pi

  • The Raspberry Pi toolchain

  • A minimal raspbian sysroot

  • Is it free to use? QtRpi is a completely free and open-source. It relies on the MIT Licence. In short, you can do whatever you want.

Everything is hosted on GitHub:

What versions of Qt is available?

Supported versions of Qt:

  • Qt 5.7.0
  • Qt 5.6.2 (LTS)

Which Qt modules are bundled in the package?

Today, the following modules are cross-compiled in the bundle:

  • qtbase ((bin/qmake, bin/rcc, bin/uic, bin/moc, libQt5Core, libQt5Gui, ...)
  • qt3d (libQt53DCore, libQt53DInput, libQt53DQuick, ...)
  • qtdeclarative (bin/qml, bin/qmlscene, libQt5Qml, libQt5Quick, libQt5QuickParticles, libQt5QuickWidgets, ...)
  • qtquickcontrols (qml/QtQuick)
  • qtquickcontrols2 (libQt5LabsControls, qml/Qt/labs)
  • qtserialport (QSerialPort)
  • qtsvg (QtSvg)

What was used to create QtRpi?

QtRpi relies on multiple components:

What version of Raspberry Pi is supported?

Right now, we support the following versions of Raspberry Pi:

  • Raspberry Pi 1
  • Raspberry Pi 2
  • Raspberry Pi 3

What do I need to use Qtrpi?

To use Qtrpi, you need the following:

  • A 64-bit linux system
  • an SSH reachable RaspberryPi with Raspbian installed

Right now, Qtrpi has been tested on an Ubuntu system. If you used something else (other Linux distro, macOS, Windows with Bash / Cygwin), please tell us!

How to install QtRpi?

QtRpi requires a couple of tasks to be properly installed on both your computer and your Raspberry Pi. To make the installation easier, we created a script to automatically perform all the steps for you. This script, init-qtrpi-minimal.sh, can be found on our QtRpi repository on GitHub.

32-bit linux host is currently not supported

Alt text

1. Clone the repository on your computer

git clone https://github.com/neuronalmotion/qtrpi.git
cd qtrpi

or download the ZIP file.

2. Configure your environment variables

The script supports multiple versions of Qt and Raspberry Pi. If you want to install a specific version of QtRpi, set the following environment variables:

Name Description Supported values Default value
QTRPI_QT_VERSION The version of the Qt framework 5.6.2
5.7.0
5.7.0
QTRPI_TARGET_DEVICE The version of the Raspberry Pi board linux-rasp-pi-g++
linux-rasp-pi2-g++
linux-rpi3-g++
linux-rasp-pi2-g++
QTRPI_TARGET_HOST The Raspberry Pi SSH host name (usually the IP of your board) user@ip None

Here is an example to configure qtrpi with Qt 5.6.2 on a Raspberry Pi 3 (you can do this in your terminal or add it to your /home/user/.bashrc):

export QTRPI_QT_VERSION='5.6.2'
export QTRPI_TARGET_DEVICE='linux-rpi3-g++'
export QTRPI_TARGET_HOST='[email protected]'

The last export QTRPI_TARGET_HOST should contain the IP address of your Raspberry Pi. This variable will be picked later by the deploy-qtrpi.sh script to deploy the Qt binaries.

3. Run the script

Once the environment variables are set, execute the following command (from your cloned repository of qtrpi):

./init-qtrpi-minimal.sh

4. Check your installation

At the end of the execution of the script, you should have a new directory /opt/qtrpi with:

  • bin: that contains qmake-qtrpi, a symbolic link to the pre-configured qmake
  • raspbian: the sysroot
  • raspi: the toolchain, the preconfigured Qt, the precompiled Qt for Raspberry Pi

5. Deploy on your Raspberry Pi

Once your Raspberry Pi is reachable within your network, execute:

./deploy-qtrpi.sh --prepare-rpi

This script will connect to your Raspbery Pi and install / update everything that is needed to run Qt applications.

The script will use sudo several times to install the packages on the board. You should add your SSH key in your Raspberry Pi (using ssh-copy-id for example) or update your /home/user/.netrc to avoid retyping pi's user password.

At the end of the script, your Raspberry Pi should contain the directory /usr/local/qt5pi with the the precompiled Qt for Raspberry Pi.

6. Export the QtRpi bin path (optional)

Add the directory /opt/qtrpi/bin to your PATH.

export PATH=/opt/qtrpi/bin:$PATH # Add this line to your /home/user/.bashrc
source ~/.bashrc

How to use QtRpi?

Now that QtRpi is installed on your computer and deployed to your Raspberry Pi, you can cross-compile Qt applications. You can do it easily on your project with qmake-qtrpi.

cd myproject
/opt/qtrpi/bin/qmake-qtrpi # the full path can be omitted if you added /opt/qtrpi/bin to your PATH
make

The generated binary file is ready to be copied and executed on your Raspberry Pi!

How to configure Qt Creator to use QtRpi?

We published a video on Youtube to describe the configuration of Qt Creator with QtRpi. With this configuration you will have:

  • A custom Qt kit that will let you cross-compile Qt applications (with the speed of your computer's CPUs) for your Raspberry Pi
  • An automatic deployment configuration that will copy the cross-compiled binary to your Raspberry Pi
  • A remote debugger that will enable you to execute your program step by step directly on your Raspberry Pi

The only step that you have to do before watching the video is to install the multi-architecture debugger (gdb-multiarch):

sudo apt-get install gdb-multiarch

We assume that your QtRpi is already properly installed (on your computer and Raspberry Pi).

This video targets a Raspberry Pi 3, but you can use any supported version of Raspberry Pi (1, 2, 3)

Alt text