Setting Up a Cross-Compilation Development Environment on Ubuntu 18.04 for Raspberry Pi 2/3

Overview

Cross-compilation development for Raspberry Pi boards requires both a host development system and a representative device connected together via serial and network connections. The development system will be used to write and cross-compile either libraries or applications, which will then be pushed down to the device for testing. The two systems will be referred to as host and target systems, respectively. You can run your development host using either the VM image or set up the environment on a physical system running Ubuntu 18.04 LTS.

Installing Boot2Qt Raspberry Pi SDK on development machine

We generated Rpi SDK as the last step of building Rpi image and have it as a self-extracted archive
b2qt-x86_64-meta-toolchain-b2qt-embedded-qt5-sdk-raspberrypi3.sh
in the image build directory.

Start the installer
./b2qt-x86_64-meta-toolchain-b2qt-embedded-qt5-sdk-raspberrypi3.sh

2. Agree with default location:

Boot to Qt for Embedded Linux SDK installer version 2.5.3
=========================================================
Enter target directory for SDK (default: /opt/b2qt/2.5.3):
You are about to install the SDK to “/opt/b2qt/2.5.3”. Proceed[Y/n]?
Extracting SDK……………………………………………………………………………….done
Setting it up…done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
$ . /opt/b2qt/2.5.3/environment-setup-cortexa7hf-neon-vfpv4-poky-linux-gnueabi

Now we have installed Rpi SDK under “/opt/b2qt/2.5.3” directory.

Creating new cross compiling kit for Raspberry Pi

In Qt Creator, a kit specifies the compiler and other necessary tools for building an application and for running it on a particular platform. The most important thing when cross compiling is to use the correct settings for Compiler / Qt version / Kits. This section covers the correct settings for cross-compiling for Raspberry Pi. These settings are found in the Options page.

We start configuring new kit for Raspberry Pi device with creating new device.

Go to the Options form (Tools > Option > Devices) from QtCreator’s main menu and choose Devices tab. Click the [Add] button and create a [Generic Linux Device].

2. Fill in the required fields:

3. If QtCreator was able to reach the device you should see this:

Click [Close] / [Apply] to finish configuring Raspberry Pi device.

Now we are ready to configure our cross development kit (debugger, cross-compilers gcc/g++, qmake)

4. Back in the Options dialog (Tools > Options > Kits > Debuggers) and add a debugger from the SDK we just installed in the previous chapter. It can be found in cross toolchain directory
“/opt/b2qt/2.5.3/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi”
Treating vaginal dryness by improving diet can be a condition by which pregnant females have significantly higher degrees of blood glucose viagra on line cheap no matter the lack of any past signs with diabetes. This could make you see with a blue tint india pharmacies levitra for up to a few hours of taking the drug. But since you are not interacting with the physician If notice any side effect, then seek medical assistance immediately and take wise steps before the condition gets cheapest levitra pills poorer if not controlled o time.The causes of erectile deficiency includes physiological or psychological, or sometimes both. Today there are numerous service providers that proffer this exclusive medicine is termed as cheap viagra cialis magical medicine for men who are planning a romantic weekend. as “arm-poky-linux-gnueabi-gdb”

Click [Apply] to complete this step.

5. Now switch to Compilers page. Select [Add] and choose gcc/g++ cross compilers from the cross toolchain directory. Click [Apply] to complete this step.

6. Switch to Qt Versions page to add the desired Qt version to the kit’s configuration. Select [Add…] and choose “qmake”, located in “/opt/b2qt/2.5.3/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi” directory.
Click [Apply] to complete this step.

7. Create a new kit named Rpi3. Select <Tools > Options > Kits> and click [Add]. Fill in the fields as shown below and click [OK] to complete new kit configuration.

Testing new cross-compiling kit

Once new development kit is installed and configured you can build a simple QML based application.

Open Qt Creator and select: File >New File or Project
Then Application >Qt Quick Application – Scroll

Choose the project’s name and location (i.e. readDht22 and /home/qdev/projects)
Choose the right development kit

And finally build your test application

Deploying a Qt application to a Remote Device

Once the application has been built, you will need to deploy it to the target device (Raspberry Pi). There are two options for moving the binary to the remote device:

A. Copy the files using scp (from a terminal window)
B. Use Qt Creator’s one-button deployment feature

Once configured, the second option allows you to deploy directly to the Raspberry Pi board from within Qt Creator. To configure this feature append the following to readDht22.pro file:

target.path = /opt/examples/bin
INSTALLS += target

To deploy the application, selecting Build->Deploy Project . This will move a binary file(s) from your project’s build directory on the host system to “/opt/examples/bin” on the device. Note, the device must be running and have the IP address defined in Qt Creator’s Device form.