Building FlightGear - Devuan

From FlightGear wiki
Jump to navigation Jump to search

How-To build FlightGear on Devuan GNU/Linux Stable (Daedalus). Instructions probably apply to Debian GNU/Linux Bookworm, too.

The meaning of this article is to be a short, checklist like, overview of the specific steps to compile FlightGear and components on Devuan. For more detailed information please refer to the main article Building FlightGear on Linux.

Zeichen 144 icon.png For beginners with compiling it is highly recommended to follow this guide step by step. Any modification to most of the herein used commands will cause trouble.


Requirements and Preparations

A bunch of packages (as well as some of their dependencies) are required to compile FlightGear:


Tools

su - -c "apt-get install cmake g++ gcc git make sed"


Dependencies

If you prefer you might replace libcurl4-openssl-dev by libcurl4-gnutls-dev.
For VR support add package libopenxr-dev to the list below.
Zeichen 144 icon.png During installation development packages of libraries which are going to be compiled must not be installed. They can safely be re-installed after compilation. Namely these are libc-ares-dev, libplib-dev, libpopenscenegraph-dev and libsimgear-dev.
su - -c "apt-get remove libc-ares-dev libopenscenegraph-dev libplib-dev libsimgear-dev"
su - -c "apt-get install freeglut3-dev libavcodec-dev libavformat-dev libboost-dev libc-ares-dev libcurl4-openssl-dev libdbus-1-dev libeudev-dev libevent-dev libfreetype6-dev libglew-dev libjpeg62-turbo-dev liblzma-dev libopenal-dev libqt5quick5 libqt5svg5-dev librsvg2-dev libswscale-dev libxi-dev libxmu-dev pkg-config qtbase5-dev qtbase5-private-dev qtdeclarative5-dev qttools5-dev zlib1g-dev"


Build and install

Some things require customisation. We'll use environment variables for them:

FG_VERSION – The version of FlightGear to build and install. This is either next (for the bleeding edge development branch) or a release number in the form release/2024.1. For a list of valid releases see here.
FG_SRC_DIR – The absolute path to the directory which is supposed to hold the source codes. In case your user belongs to the group staff, /usr/local/src/ would be an appropriate location. But any location is fine, too, e.g. $HOME/src/. In any case the user has to have write access there.
FG_INSTALL_DIR – The absolute path to where FlightGear is going to be installed. Again, /usr/local/ is appropriate, if your user belongs to staff. But any location where the user has write access is ok, e.g. $HOME/FlightGear/.
# Examples, adapt to your own needs:
export FG_VERSION=release/2024.1   #OR#   export FG_VERSION=next
export FG_SRC_DIR=$HOME/src/
export FG_INSTALL_DIR=$HOME/FlightGear/
Remember to export these variables in each console you use in the process.

From here on it should™ be possible to just copy and paste the entire content of each code box at once into the console.

# Create specified directories if they do not exist:
mkdir -p $FG_SRC_DIR
mkdir -p $FG_INSTALL_DIR

For more/advanced cmake options and SimGear's and FlightGear's optional features see the cmake article.

Zeichen 144 icon.png Do not mix versions for SimGear, FlighGear and fgdata! Mixing versions will almost certainly break the installation.


libc-ares

This step is only required to compile FlightGear 'next':

cd $FG_SRC_DIR
git clone https://github.com/c-ares/c-ares.git libc-ares.git
cd libc-ares.git
git checkout v1.34
mkdir -p $FG_SRC_DIR/build-c-ares && cd $FG_SRC_DIR/build-c-ares
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX="$FG_INSTALL_DIR" $FG_SRC_DIR/libc-ares.git
make -j$(nproc)
make install


libplib

While just installing package libplib-dev should work, it's recommended to build it from source. In this case libplib-dev must not be installed during the installation process of Simgear and Flightgear!

cd $FG_SRC_DIR
git clone git://git.code.sf.net/p/libplib/code libplib.git
cd libplib.git
echo "1.8.6" > version
sed s/PLIB_TINY_VERSION\ \ 5/PLIB_TINY_VERSION\ \ 6/ -i src/util/ul.h
git commit --all --message "Increase tiny version to 6."
mkdir -p $FG_SRC_DIR/build-plib && cd $FG_SRC_DIR/build-plib
cmake -D CMAKE_INSTALL_PREFIX:PATH="$FG_INSTALL_DIR" $FG_SRC_DIR/libplib.git
make -j$(nproc)
make install


OpenSceneGraph

To compile FlightGear release version branch release/2024-build is required, for FlightGear next branch next.

if [ "$FG_VERSION" = "release/2024.1" ]; then export FG_OSG_VERSION=release/2024-build; fi
if [ "$FG_VERSION" = "next" ]; then export FG_OSG_VERSION=next; fi
cd $FG_SRC_DIR
git clone https://gitlab.com/flightgear/openscenegraph.git FG-OpenSceneGraph.git
cd FG-OpenSceneGraph.git
git checkout $FG_OSG_VERSION
mkdir -p $FG_SRC_DIR/build-osg && cd $FG_SRC_DIR/build-osg
cmake -D LIB_POSTFIX="" -D CMAKE_INSTALL_PREFIX:PATH="$FG_INSTALL_DIR" $FG_SRC_DIR/FG-OpenSceneGraph.git
make -j$(nproc)
make install


SimGear

cd $FG_SRC_DIR
git clone git://git.code.sf.net/p/flightgear/simgear simgear.git
cd simgear.git
git checkout $FG_VERSION
mkdir -p $FG_SRC_DIR/build-sg && cd $FG_SRC_DIR/build-sg
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX:PATH="$FG_INSTALL_DIR" $FG_SRC_DIR/simgear.git
make -j$(nproc)
make install


FlightGear data

mkdir -p $FG_INSTALL_DIR/share && cd $FG_INSTALL_DIR/share
git clone git://git.code.sf.net/p/flightgear/fgdata fgdata
cd fgdata
git checkout $FG_VERSION


FlightGear source

cd $FG_SRC_DIR
git clone git://git.code.sf.net/p/flightgear/flightgear flightgear.git
cd flightgear.git
git checkout $FG_VERSION
mkdir -p $FG_SRC_DIR/build-fg && cd $FG_SRC_DIR/build-fg
cmake -D CMAKE_BUILD_TYPE=Release -D FG_BUILD_TYPE=Release -D FG_DATA_DIR:PATH="$FG_INSTALL_DIR/share/fgdata" -D CMAKE_INSTALL_PREFIX:PATH="$FG_INSTALL_DIR" $FG_SRC_DIR/flightgear.git
make -j$(nproc)
make install


Trial run and finishing process

When all the builds are done and the data download has finished it is time for a test run. In case your FG_INSTALL_DIR is /usr/local/, just run fgfs --launcher.

In case it's anywhere else on the system, things are a tad more complicated:

export LD_LIBRARY_PATH=$FG_INSTALL_DIR/lib/:$LD_LIBRARY_PATH
$FG_INSTALL_DIR/bin/fgfs --launcher
The fgfs binary needs to find our self compiled libraries at runtime and therefore we have to tell the linker (ld) where to find them. That is what the first line here does.
Since $PATH most likely does not cover the FG_INSTALL_DIR, the full path to the fgfs binary is required to run it.
Even though it's a tad more laborious than installing it to /usr/local/, this approach has the advantage of easlily managing several FlightGear installations.

To make it permanent and less complicated one option would be to create an alias:

echo -e "alias fgfs='LD_LIBRARY_PATH=$FG_INSTALL_DIR/lib/:$LD_LIBRARY_PATH $FG_INSTALL_DIR/bin/fgfs' \n" >> $HOME/.bashrc
source $HOME/.bashrc
Now running fgfs --launcher will start the simulator.

To keep the source code git repos up to date have a look at our git for laymen section.


Uninstalling

To uninstall Flightgear and its components from e.g. /usr/local/, run make uninstall inside each software's build directory:

cd $FG_SRC_DIR/build-fg && make uninstall
cd $FG_SRC_DIR/build-sg && make uninstall
cd $FG_SRC_DIR/build-osg && make uninstall; rm -R $FG_SRC_DIR/lib/osgPlugins-3.6.5
rm -RI $FG_INSTALL_DIR/include/plib; rm $FG_INSTALL_DIR/lib/libplib*.a
rm -RI $FG_INSTALL_DIR/share/fgdata

Please report issues or any kind of feedback to the talk page.