Servers by jDrones

How to cross-compile QGroundControl for Raspberry Pi3

(Aleksander) #1

Hello, I just got QGCS to run on a Raspberry Pi3 with the original Raspberry 7" touch display. For those of you that are interested, this is how I made it work.


  1. Raspberry Pi3
  2. Host computer running Ubuntu 16.04 64bit

Prepare the RPi3
Install fresh copy of the latest Raspbian OS

Update the RPi3

Edit sources list in /etc/apt/sources.list and uncomment the deb-src line:

sudo nano /etc/apt/sources.list

sudo apt-get update
sudo apt-get dist-upgrade
sudo reboot

sudo rpi-update
sudo reboot

Make some directories and changing some permissions on the RPi3

sudo mkdir /usr/local/qt5pi
sudo chown 1000:1000 /usr/lib/cups/backend/vnc

Install dependencies on the RPi3

sudo apt-get build-dep qt4-x11
sudo apt-get build-dep libqt5gui5
sudo apt-get install libudev-dev libinput-dev libts-dev libxcb-xinerama0-dev libxcb-xinerama0
sudo apt-get install speech-dispatcher libudev-dev libsdl2-dev libgstreamer1.0-0 gstreamer1.0-plugins-base libgstreamer-plugins-base1.0-dev

You also need to enter the raspi-config tool and do some changes:

sudo raspi-config

Inside the raspi-config tool:

“Advanced Options” -> “Memory Split” -> 256
"Advanced Options" -> “GL Driver” -> “GL (Fake KMS) OpenGL desktop driver with fake KMS”

Press finish and reboot.

Leave the RPi3 on.

Preparing the host computer


sudo apt-get update
sudo apt-get -y upgrade

Install dependencies

sudo apt-get install git bison python gperf

Also download QT Creator and chose QT5.9.3

Generate public SSH key

ssh-keygen -t rsa -C pi@raspberrypi.local -N "" -f ~/.ssh/id_rsa
cat ~/.ssh/ | ssh -o StrictHostKeyChecking=no pi@raspberrypi.local "mkdir -p .ssh && chmod 700 .ssh && cat >> .ssh/authorized_keys"

Create a folder for our project

sudo mkdir /opt/qt5pi
sudo chown 1000:1000 /opt/qt5pi
cd /opt/qt5pi

Get the toolchain for the RPi


tar -xvf gcc-linaro-5.5.0-2017.10-x86_64_arm-linux-gnueabihf.tar.xz

Add toolchain binary directory to PATH. Open .bashrc and add line at end of file

sudo nano ~/.bashrc

export PATH=$PATH:/opt/qt5pi/gcc-linaro-5.5.0-2017.10-i686_arm-linux-gnueabihf/bin

To activate this changes, you have to restart the terminal and:

cd /opt/qt5pi

Get the QT sources


tar xf qt-everywhere-opensource-src-5.9.3.tar.xz

Get the RPi3 sysrot

mkdir sysroot sysroot/usr sysroot/opt
rsync -avz pi@raspberrypi.local:/lib sysroot
rsync -avz pi@raspberrypi.local:/usr/include sysroot/usr
rsync -avz pi@raspberrypi.local:/usr/lib sysroot/usr
rsync -avz pi@raspberrypi.local:/opt/vc sysroot/opt

Convert absolute symlinks into relative symlinks

chmod +x
./ sysroot

Make your build folder

mkdir qt5build

Configure your cross-compiled QT

cd qt5build
../qt-everywhere-opensource-src-5.9.3/configure -opengl es2 -device linux-rasp-pi3-vc4-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot /opt/qt5pi/sysroot -prefix /usr/local/qt5pi -opensource -confirm-license -skip qtwebengine -skip qtscript -nomake tests -nomake examples -no-use-gold-linker -make libs -v

This operation should finish without errors before you continue with the next step

Make QT

make install

Upload QT to the RPi3

cd /opt/qt5pi
rsync -avz sysroot/usr/local/qt5pi pi@raspberrypi.local:/usr/local 

Qt configuration

Open QtCreator

Generic Linux Device
Edit Hostname, authentication type key, username and add private key ( ~/.ssh/id_rsa )

Edit name and path ( /opt/qt5pi/gcc-linaro-5.5.0-2017.10-i686_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gdb )

Edit name and path ( /opt/qt5pi/gcc-linaro-5.5.0-2017.10-i686_arm-linux-gnueabihf/binarm-linux-gnueabihf-gcc )

Edit name and path ( /opt/qt5pi/gcc-linaro-5.5.0-2017.10-i686_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ )

Tools->Qt Versions->Add
Choose /opt/qt5pi/sysroot/usr/local/qt5pi/bin/qmake

Edit name to: RaspberryPi
Device type: Generic Linux Device
Device: Choose prior created raspberry pi device
Sysroot: Choose /opt/qt5pi/sysroot
C and C++: Choose prior created raspberry pi compilers
Debugger: Choose prior created raspberry pi debugger
Qt version: Choose prior created raspberry pi qt version

Compile QgroundControl

On the host computer:

git clone --recursive

In Qt Creator: File -> Open File or Project -> Open

Chose the RaspberryPi kit you just created in the previous steps and open the project.
Expand the qgroundcontrol master tree inside Qt Creator and open the file QGCCommon.pri and add edit line 28 to:

} else : linux-rasp-pi3-vc4-g++ {

Now it should be possible to build the project by pressing the “hammer” button on the low left hand side. Be sure that you build with the RaspberryPi kit you created.

When Qgroundcontrol is built you have to transfer the files to the RaspberryPi, you can do this with:

rsync -avz build-qgroundcontrol-RaspberryPi-Release pi@raspberrypi.local:/home/pi

from the host computer.

Launch Qgroundcontrol on the RPi3

Boot the system into Raspbian PIXEL, open a terminal and type:

./build-qgroundcontrol-RaspberryPi-Release/release/ -platform xcb

Happy flying with your new compact GCS solution!

If you have any comment or other ideas please discuss here =)


Has anybody managed to get QGroundControl GCS working on RPi?
(Fnoop) #2

Holy cr4p you’re determined!!!
There’s something wrong somewhere if it’s this difficult to build it…
Would you consider posting a zip of the build on github or somewhere, so people can just download and run it?

(cala2) #3

Mission plane works too? Thank’s

(Aleksander) #4

@fnoop yes I can. But I need to do some more fine tuning :slight_smile: Are you planning to use the official raspberry 7 " display?

And I need to figure out how I can make a bootable image off my setup :):joy:

(Eric) #5

Great work!! Thank you for taking the time to do this, we are all in your debt. Is there a way to do this without a Linux computer? All I have are windows computers. I am very interested in getting this working on my RP3 and 5" lcd.

(John Longland) #6

Good day Aleksander

I have been reading the thread from beginning. Cool stuff !! I wonder if one could simply substitute “Tower” ( ) into the place of “QGroundcontrol”?


(DonLakeFlyer) #7

Tower is an Android application which will only run on Android OS.

(alexxtasi) #8

Hi @JAR4x4 and thanks for the great news !
I tried the procedure you provided, but in the step Configure your cross-compiled QT and when configuring qt in command:

../qt-everywhere-opensource-src-5.9.3/configure -opengl es2 -device linux-rasp-pi3-vc4-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot /opt/qt5pi/sysroot -prefix /usr/local/qt5pi -opensource -confirm-license -skip qtwebengine -skip qtscript -nomake tests -nomake examples -no-use-gold-linker -make libs -v

I have errors:

Command line: -opengl es2 -device linux-rasp-pi3-vc4-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot /opt/qt5pi/sysroot -prefix /usr/local/qt5pi -opensource -confirm-license -skip qtwebengine -skip qtscript -nomake tests -nomake examples -no-use-gold-linker -make libs -v

Project ERROR: Cannot run target compiler 'arm-linux-gnueabihf-g++'. Maybe you forgot to setup the environment?

Since I have little experience in configuring systems, can you please help me on finding the problem ??
I have followed all the suggested commands and in the host pc, ubuntu 18.04 is installed.


Gave it a try on Ubuntu 16.04 64bit… just in case…
The same error came up -(
I have to mention that above the error (in both attempts) this message is printed:

Info: creating super cache file /opt/qt5pi/qt5build/.qmake.super

(Aleksander) #9

Sorry for my late reply, @alexxtasi Is it a Pi 3 or Pi 3 B+ you are building for?

I will also check my notes and se if I have written something wrong in the instructions


(alexxtasi) #10

Hi @JAR4x4
As far as I know it’s Pi3 model B (if Pi3 B+ is the newest model, surely I have Pi3)

  • is there a way to clear this out?
  • I’m trying the hole process (the host pc from the steps you provided) on a vm… does this matter ?


(Aleksander) #11


I don’t know if this will work from a VM… Can you try from a ubuntu 16.04 box?

(alexxtasi) #12

I will… as soon as I have a pc handy (on vacation now :slight_smile: ) … its the next thing I am going to try.
I’ll let you know

(anon67614380) #13

Any chance we could have an image of this, so we can flash it and fly?

A lot of people (myself included) do not have an ubuntu machine handy.


(Aleksander) #14

I can try to make an image. I have just moved, so my workshop is still in boxes :frowning: When I have everything up and running again I will make a image. Hopefully this will happen in a week or two.


(anon67614380) #15

That would be great thanks.


(alexxtasi) #16

Hi there
I borrowed a laptop and tried again (installed Ubuntu 16.04 64bit)
Unfortunately the exact same error occurred !
when running:

../qt-everywhere-opensource-src-5.9.3/configure -opengl es2 -device linux-rasp-pi3-vc4-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot /opt/qt5pi/sysroot -prefix /usr/local/qt5pi -opensource -confirm-license -skip qtwebengine -skip qtscript -nomake tests -nomake examples -no-use-gold-linker -make libs -v

after several line of output, this is printed:

Info: creating super cache file /opt/qt5pi/qt5build/.qmake.super
Command line: -opengl es2 -device linux-rasp-pi3-vc4-g++ -device-option CROSS_COMPILE=arm-linux-gnueabihf- -sysroot /opt/qt5pi/sysroot -prefix /usr/local/qt5pi -opensource -confirm-license -skip qtwebengine -skip qtscript -nomake tests -nomake examples -no-use-gold-linker -make libs -v
Project ERROR: Cannot run target compiler 'arm-linux-gnueabihf-g++'. Maybe you forgot to setup the environment?

I think I run the commands correctly…
is there any test I should do ?

(davidbitton) #17

How is the performance? Can I use a joystick to control the craft via telemetry and QGC? Is there a “SiK radio” shield for RiP or is USB the way to go?

(Aleksander) #18


These instructions are now obsolete due to a change in QT version for QGCS. I’m working on making new instructions. I tried joystick with the old version, it worked, but without buttons. I’ve read that buttons should work with QGSC and Ardupilot now

(davidbitton) #19

thanks for the update