Skip to content

Instantly share code, notes, and snippets.

@vlj91
Created July 28, 2020 10:15
Show Gist options
  • Save vlj91/e2553bbd1ae285b1c47650b65defd349 to your computer and use it in GitHub Desktop.
Save vlj91/e2553bbd1ae285b1c47650b65defd349 to your computer and use it in GitHub Desktop.
qgroundcontrol-install.sh
# building qgroundcontrol for raspberry pi 4
# steps:
# 1. compile QT for raspberry Pi:
# - the version of QT that comes with debian doesn't compile
# QGC correctly, so we compile a newer version
# - this can take up to 8 hours even with 4 cores
# 2. compile qtlocation
# 3. compile qgroundcontrol using qt5.12.8
# this assumes a desktop environment is present to actually run qgc once it's compiled
###############################################################################
# QT COMPILE
###############################################################################
QT_MAJOR_VERSION="5.12"
QT_MINOR_VERSION="8"
QT_FULL_VERSION="${QT_MAJOR_VERSION}.${QT_MINOR_VERSION}"
QT_BASE_URL="http://download.qt.io/official_releases/qt"
QT_VERSION_URL="${QT_BASE_URL}/${QT_MAJOR_VERSION}/${QT_FULL_VERSION}/single"
QT_CHECKSUMS_URL="${QT_VERSION_URL}/md5sums.txt"
QT_PACKAGE_NAME="qt-everywhere-src-${QT_FULL_VERSION}.tar.xz"
QT_SOURCE_URL="${QT_VERSION_URL}/${QT_PACKAGE_NAME}"
wget "${QT_VERSION_URL}/${QT_PACKAGE_NAME}"
QT_SOURCE_CHECKSUM=$(curl $QT_CHECKSUMS_URL | grep "${QT_PACKAGE_NAME}" | awk '{print $1}')
QT_LOCAL_CHECKSUM=$(md5sum "${QT_PACKAGE_NAME}" | grep "${QT_PACKAGE_NAME}" | awk '{print $1}')
if [[ "${QT_SOURCE_CHECKSUM}" != "${QT_LOCAL_CHECKSUM}" ]]; then
echo "Checksums do not match"
exit
fi
sudo apt update -y
sudo apt install -y \
build-essential \
libfontconfig1-dev \
libdbus-1-dev \
libfreetype6-dev \
libicu-dev \
libinput-dev \
libxkbcommon-dev \
libsqlite3-dev \
libssl-dev \
libpng-dev \
libjpeg-dev \
libglib2.0-dev \
libraspberrypi-dev \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-ugly \
gstreamer1.0-plugins-bad \
libgstreamer-plugins-bad1.0-dev \
gstreamer1.0-pulseaudio \
gstreamer1.0-tools \
gstreamer1.0-alsa \
libasound2-dev \
pulseaudio \
libpulse-dev \
libpq-dev \
libmariadbclient-dev \
libcups2-dev \
libwayland-dev \
libx11-dev \
libxcb1-dev \
libxkbcommon-x11-dev \
libx11-xcb-dev \
libxext-dev
tar xfv "${QT_PACKAGE_NAME}"
# we need some custom config files in order to build Qt on raspberry pis
# this repository seems to have the configs for each rpi version
git clone "https://github.com/oniongarlic/qt-raspberrypi-configuration.git"
pushd qt-raspberrypi-configuration
make install DESTDIR="../qt-everywhere-src-${QT_FULL_VERSON}"
popd
mkdir build
pushd build
# default platform flag: linux-rpi-g++
PKG_CONFIG_LIBDIR=/usr/lib/arm-linux-gnueabihf/pkgconfig:/usr/share/pkgconfig \
"../qt-everywhere-src-${QT_FULL_VERSION}/configure" \
-platform linux-rpi4-v3d-g++ \
-v \
-opengl es2 \
-eglfs \
-no-gtk \
-opensource \
-confirm-license \
-release \
-reduce-exports \
-force-pkg-config \
-nomake examples \
-no-compile-examples \
-skip qtwebengine \
-no-feature-geoservices_mapboxgl \
-qt-pcre \
-no-pch \
-ssl \
-evdev \
-system-freetype \
-fontconfig \
-glib \
-prefix "/opt/Qt${QT_MAJOR_VERSION}" \
-qpa eglfs
make -j$(nproc) # this step takes hours
sudo make install
popd
###############################################################################
# QTLOCATION COMPILE
###############################################################################
sudo apt install -y \
libudev-dev \
libinput-dev \
libts-dev \
libxcb-xinerama0-dev \
libxcb-xinerama0 \
speech-dispatcher \
libudev-dev \
libsdl2-dev \
libgstreamer1.0-0 \
gstreamer1.0-plugins-base \
libgstreamer-plugins-base1.0-dev \
libssl-dev
if [[ -d "./qtlocation/" ]]; then
rm -rfv "./qtlocation"
fi
git clone https://github.com/qt/qtlocation
pushd qtlocation
git checkout "v${QT_FULL_VERSION}"
mkdir build
pushd build
/opt/Qt${QT_MAJOR_VERSION}/bin/qmake ../qtlocation.pro
make -j$(nproc)
sudo make install
popd
popd
###############################################################################
# QGROUNDCONTROL COMPILE
###############################################################################
QGC_VERSION="v3.5.4"
if [[ -d "./qgroundcontrol" ]]; then
rm -rfv "./qgroundcontrol"
fi
git clone https://github.com/mavlink/qgroundcontrol
pushd qgroundcontrol
git checkout "${QGC_VERSION}"
mkdir build
pushd build
git submodle init
git submodule update
/opt/Qt${QT_MAJOR_VERSION}/bin/qmake -r ../qgroundcontrol.pro CONFIG+=release CONFIG+=exceptions
popd
popd
# run with ./qgroundcontrol-start.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment