Building Flightgear - Raspbian

From FlightGear wiki
Jump to navigation Jump to search

Preparation

An installation of Raspbian Buster Lite is needed

Requirements

All the commands are run in bash as normal pi user (not root). The pi user needs sudo access to install packages.

The following packages need to be install on the the system before starting the build of FlightGear. The packages can be install using the apt command:

sudo apt install libplib-dev cmake g++ libboost-all-dev libopenal-dev libglew-dev \
    libcurl4-openssl-dev libfreetype6-dev \
    libqt5svg5-dev qttools5-dev qtdeclarative5-private-dev qtbase5-private-dev libqt5websockets5-dev qml-module-qtquick2

Setup pbuilder

First, pbuilder has to be installed:

sudo apt install pbuilder quilt

Create a base chroot image tar-ball if it has not been created before:

sudo pbuilder create \
    --distribution "buster" \
    --basetgz "/var/cache/pbuilder/base-buster-armhf.tgz" \
    --debootstrapopts --keyring=/usr/share/keyrings/raspbian-archive-keyring.gpg

If the base chroot image tar-ball has been created before, update it:

sudo pbuilder \
    --update \
    --basetgz "/var/cache/pbuilder/base-buster-armhf.tgz"

libcollada-dom2.4

libcollada-dom2.4-dp0 has been build for Raspbian 9 not 10. The package has still dependencies to libboost-filesystem1.58.0 and libboost-system1.58.0 [1].

The package needs to be rebuild using for example pbuilder:

apt source libcollada-dom2.4-dp0
pushd -- collada-dom-2.4.4+ds1
dpkg-buildpackage -S -d -us -uc
popd
rm -Rf -- collada-dom-2.4.4+ds1
sudo pbuilder --build --basetgz /var/cache/pbuilder/base-buster-armhf.tgz collada-dom_2.4.4+ds1-2.dsc

and then installed:

sudo dpkg --install /var/cache/pbuilder/result/libcollada-dom2.4-dp0_2.4.4+ds1-2_armhf.deb \
    /var/cache/pbuilder/result/libcollada-dom2.4-dp-dev_2.4.4+ds1-2_armhf.deb

OpenSceneGraph

The osgPlugins-3.4.1/osgdb_png.so is not compiled on ARM due to the flag OSG_CPP_EXCEPTIONS_AVAILABLE:BOOL=OFF. The package needs to be rebuild using for example pbuilder after changing OSG_CPP_EXCEPTIONS_AVAILABLE:BOOL=ON [2]:

apt source openscenegraph-3.4
pushd -- openscenegraph-3.4-3.4.1+dfsg1

Now modify the debian/rules file:

nano debian/rules

and change OSG_CPP_EXCEPTIONS_AVAILABLE:BOOL=OFF by OSG_CPP_EXCEPTIONS_AVAILABLE:BOOL=ON. To prevent to run out of memory during the build (4 cores for only 1 Gb of memory in the case of the Raspberry Pi 2/3/3+), --parallel can be replaced by --parallel 1 or --parallel 2.

dpkg-buildpackage -S -d -us -uc
popd
rm -Rf -- openscenegraph-3.4-3.4.1+dfsg1
sudo pbuilder --build --basetgz /var/cache/pbuilder/base-buster-armhf.tgz openscenegraph-3.4_3.4.1+dfsg1-5.dsc

and then installed:

sudo dpkg --install /var/cache/pbuilder/result/libopenscenegraph-3.4-131_3.4.1+dfsg1-5_armhf.deb \
    /var/cache/pbuilder/result/openscenegraph-3.4_3.4.1+dfsg1-5_armhf.deb \
    /var/cache/pbuilder/result/openscenegraph-3.4-examples_3.4.1+dfsg1-5_all.deb  \
    /var/cache/pbuilder/result/libopenscenegraph-3.4-dev_3.4.1+dfsg1-5_armhf.deb

Compiling

The Raspberry Pi 1/2/3/3+ only supports OpenGL ES 2.0. Simgear still contains some OpenGL 1 instructions (fixed pipeline, not shaders). On Raspbian, the Mesa package uses the accelerated KMS back-end that only supports, as expected, OpenGL ES 2.0. The graphical part of Simgear fails to compile on Raspbian when an OpenGL 1 instruction is used. For this reason, the following flag has to be added to cmake when compiling Simgear:

-DSIMGEAR_HEADLESS=ON