How to cross-compile QGroundControl for Raspberry Pi3

@kikislater my setup now includes two RPi’s in my GCS with one 7" screen each. One runs OpenHD for RC and FPV, the other is supposed to run QGCS for mission planning.

I’m using a custom joystick board, and everything is mounted in a small Peli case, i will post pictures later

2 Likes

So, here is short guide how to build QGC on Raspbian Buster with default Qt5 from repos. The exact steps and dependencies may vary, depend on what was already installed on your system:

  • Get the last Rasbian Buster image
  • Update and upgrade it
  • Into raspi-config:
    • “Advanced Options” -> “Memory Split” -> 256
    • “Advanced Options” -> “GL Driver” -> “GL (Fake KMS) OpenGL desktop driver with fake KMS”
  • Install dependencies from this guide:
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
  • Install Qt5 dependencies:
sudo apt install qt5-default qtbase5-private-dev qtbase5-dev qtbase5-dev-tools libqt5texttospeech5-dev libqt5svg5-dev qtmultimedia5-dev libqt5serialbus5-dev libqt5charts5-dev libqt5serialport5-dev qtdeclarative5-private-dev qttools5-private-dev qtquickcontrols2-5-dev libssl-dev
  • Install gstreamer plugins if you want videostreaming
  • You need to build QtLocation from sources, because QGC requires location-private and positioning-private which is not available into repos:
git clone https://github.com/qt/qtlocation.git
cd qtlocation
git checkout v5.11.3
mkdir build
cd build/
qmake ../qtlocation.pro
make -j4
sudo make install
  • git clone https://github.com/mavlink/qgroundcontrol.git
  • cd qgroundcontrol && mkdir build && cd build
  • git submodule update --init --recursive
  • I didn’t yet resolve the issue with missing “texttospeech” plugin, so just make an empty directory for successfull building: sudo mkdir /usr/lib/arm-linux-gnueabihf/qt5/plugins/texttospeech
  • Edit your QGCCommon.pri to build everything with right flags (maybe you know the better way, but this one just works):
linux {
    linux-g++ | linux-g++-64 | linux-g++-32 | linux-clang {
#        message("Linux build")
#        CONFIG  += LinuxBuild
#        DEFINES += __STDC_LIMIT_MACROS
#        DEFINES += QGC_GST_TAISYNC_ENABLED
#        DEFINES += QGC_GST_MICROHARD_ENABLED
#        linux-clang {
#            message("Linux clang")
#            QMAKE_CXXFLAGS += -Qunused-arguments -fcolor-diagnostics
#        }
#    } else : linux-rasp-pi3-g++  {
        message("Linux R-Pi2 build")
        CONFIG += LinuxBuild
        DEFINES += __STDC_LIMIT_MACROS __rasp_pi2__
        DEFINES += QGC_GST_TAISYNC_ENABLED
        DEFINES += QGC_GST_MICROHARD_ENABLED
  • qmake -r ../qgroundcontrol.pro CONFIG+=release
  • make -j4
  • When everything will be compiled, cd to ./release directory and run ./qgroundcontrol-start.sh. It will show errors about missing QML plugins - you should apt search for them and install.
  • Enjoy!
2 Likes

@kikislater, just want to run QGC and some kind of Open.HD on one device.

1 Like

Unfortunately I met with error at the end like this:
compiling moc/moc_AirspaceManager.cpp
compiling moc/moc_VideoItem.cpp
compiling moc/moc_VideoReceiver.cpp
compiling moc/moc_VideoSurface.cpp
compiling moc/moc_SubtitleWriter.cpp
compiling moc/moc_basedelegate.cpp
compiling moc/moc_qtquick2videosinkdelegate.cpp
compiling moc/moc_qtvideosinkdelegate.cpp
compiling moc/moc_qwidgetvideosinkdelegate.cpp
linking release/QGroundControl
/usr/bin/ld: obj/RTKSettings.o: file not recognized: file truncated
collect2: error: ld returned 1 exit status
make: *** [Makefile:2262:release/QGroundControl] error 1
The raspberry pi 4B once powered off at make period for the first time.
So how could I fix this error?
Thank you so much.

I’ve tried make clean and used make to compile again and it works so good! Thank you for your guide.

1 Like

@ kpetrykin this merge with Open.HD was also my idea :slightly_smiling_face:

Great job, could you say how much RAM is used… ?

I would like to do the same thing with raspberry Pi 4 2GB or 4GB version…

Not so much. Everything have been successfylly compiled on both 2 and 4 GB versions.

I successfully compiled and started QGC on Pi 4, I just needed to add CONFIG += exceptions setting at qmake to avoid exceptions handling problems during compilation.

Additional install is required to have pixhawk communicating over usb serial with ?

1 Like

Will this work on a Pi 4?

Yes, it will work on rpi4

I get this error though.

Do you really understand what you are doing?
Do you have any experience in building something under Linux?

The error just says that you have not a “configure” file which you try to execute.
But you don’t need to build a qt5 at all, if you try to launch QGC on RPi4.

Hello KP

No i have almost no experience as I am only now trying to learn.

Is there another way of installing Qgroundcontrol on RPI4?

As far as i know, this is the only way for now - unfortunatly.

Hello Konstantin.

I am following your guide and compiling on a Raspberry pi 4 and getting this error

pi@raspberrypi:~/qtlocation/build/qgroundcontrol/build $ qmake -r …/qgroundcontrol.pro CONFIG+=release
Project MESSAGE: Qt version 5.11.3
Project MESSAGE: Linux build
Project MESSAGE: QGroundControl Development master:be64886c5 2020-02-07 13:23:03 -0800
Project MESSAGE: Release flavor
Project MESSAGE: Using Default QtLocation headers
Project MESSAGE: Skipping support for Pairing
Project MESSAGE: Using MAVLink dialect ‘ardupilotmega’.
Project MESSAGE: Skipping support for Zeroconf (unsupported platform)
Project MESSAGE: Looking for Airmap in folder “/home/pi/qtlocation/build/qgroundcontrol/libs/airmapd”, variant: “Qt.5.11”
Project MESSAGE: Including support for video streaming
Project ERROR: Unknown module(s) in QT: x11extras waylandclient

Hi ,

I am getting the same errors as Barry.

I installed the x11extras with this command:
sudo apt-get install libqt5x11extras5-dev

No I am only getting the waylandclient error and can’t solve this :confused:

Can anyone help us?

thank you and kindest regards

Hello, Simon!

Try to “apt search waylandclient” and install founded packages.

1 Like

It’s a good step to follow : looking for qt modules related to error, however It will not work you will get another error : could not find wayland-client or similar error.

If you switch to a previous branch instead of master branch, you will not get this error. According to QGC build recommandation, you need Qt 5.12 whereas raspbian buster have 5.11.3. So you need to keep QGC version lower than current :

  • 3.5.6 fails on video even with gstreamer modules installed
  • Switch back to 3.5.5 or 3.5.4 according to @kpetrykin’s build date
2 Likes

Enabling this part is very important in QGCCommon.pri. If you forgot to modify it, it will not build… and stuck on video or opengl error

3.5.4 build fine with this option and qtlocation private build, I will test other ones : 3.5.6 and 3.5.5