Fedora Packages and Compiling

From FlightGear wiki
Jump to navigation Jump to search


Users on apt-based systems can use the script download_and_compile.sh to download required development packages and compile FlightGear. Systems using dnf for package management cannot use this script. Once required packages are loaded using dnf, the download_and_compile.sh script can be used to compile and build FlightGear is desired

Here are the packages needed to build and use SimGear and FlightGear on Fedora along with some examples of build scenarios for reference.

Simply Use the Current Release

If one wishes to simply use FlightGear in its current supported form without re-compiling, the Fedora FlightGear packages are fine.

As of march 2025, the fedora 41 repository provides the current release 2024.1.1. To use simply download the Fedora FlightGear packages. It is not necessary to load these packages in order to compile and install your own versions from source, but it also is compatible with and does not prevent development work if they are installed.

sudo dnf -y install FlightGear
sudo dnf -y install FlightGear-data
sudo dnf -y install FlightGear-Atlas # Optional

This installs FlightGear commands such as fgfs in /usr/bin and FlightGear's data, fgdata, in /usr/share/flightgear.

Building FlightGear

If, however, one wishes to build various versions from source, several development packages are required.

Different packages may be needed for different versions of FlightGear. Also the FlightGear distribution contains several other commands in flightgear/utils that may require additional packages.

Required Packages

These required packages are needed in addition to the basic configuration provided by a Fedora 41 Workstation initial installation.

Required packages for the current 2024.1 release
sudo dnf -y install cmake
sudo dnf -y install gcc-c++
sudo dnf -y install boost-devel
sudo dnf -y install gtkglext-devel
sudo dnf -y install openal-soft-devel
sudo dnf -y install OpenSceneGraph-devel
sudo dnf -y install libcurl-devel
sudo dnf -y install plib-devel
sudo dnf -y install freeglut-devel
Required packages for the development 2024.2 release

2024.2 uses an updated version of OpenSceneGraph. If the Fedora-provided OpenSceneGraph-devel has been loaded, there is no conflict as we will tell the build system which to use.

sudo dnf -y install mesa-libGL mesa-libGL-devel
sudo dnf -y install mesa-libGLU mesa-libGLU-devel
sudo dnf -y install glfw glfw-devel freeglut freeglut-devel
sudo dnf -y install freetype freetype-devel
sudo dnf -y install gdal

And 2024.2 wants, but does not specifically require Qt5

sudo dnf -y install qt5-qtbase-devel
sudo dnf -y install qt5-qtdeclarative-devel
sudo dnf -y install qt5-qtsvg-devel
sudo dnf -y install qt5-linguist

Build Examples

The required development packages listed above are sufficient for building SimGear, FlightGear, loading fgdata and installing a running flight simulator. FlightGear has several additional packages that may require additional development packages. using cmake and following its errors make it fairly straight forward to find and install additional packages for these additional FlighhtGear components.

The following sections describe example scenarios for compiling and installing various versions of FlightGear.

Note that one shell variable is used in these examples to control the number of parallel processes allowed by make. Using this parallelism speed up the compilation process. Place this in your $HOME/.bashrc.

export nproc=`/usr/bin/nproc`

Two main versions are described.

Version 2024.1.1 is the current release version. One may wish to experiment and build patched versions to maintain compatibility with existing binary downloads. However it may be useful to use later development versions and contribute to the ongoing FlightGear development.

Version 2024.2, or next, is where features beyond 2024.1 continue development.

Current release version 2024.1

This example gives the simple case of a single private version in your HOME directory.

mkdir $HOME/fg2024.1
cd $HOME/fg2024.1

Two methods exist to get the required source code. Tar archives or the FlightGear git repository.

Use .tar files

The FlightGear web page Download section https://www.flightgear.org/download/ provides access to the tar files.

These tar files unpack into directories named simgear-v2024.1.1, flightgear-v2024.1.1, and fgdata_2024_1.

These directories can be named anything you wish as long as the names are used consistently. Here I will rename the extracted directory names to be consistent throughout all the following examples.

tar xzf simgear-v2024.1.1.tar.gz
mv simgear-v2024.1.1 simgear
tar xzf flightgear-v2024.1.1.tar.gz
mv  flightgear-v2024.1.1 flightgear
tar xJf FlightGear-2024.1.1-data.txz
mv fgdata_2024_1 fgdata

Use the git repository

If you are going to compile and build your own version of FlightGear, possibly fixing a personal bug or adding a feature, please consider joining the community of developers and contributing. To start, it is best to use the GitLab repositories rather than tar files so that you might contribute in the future.

For 2024.1, we clone a single branch of the repository to have a similar configuration as with the tar files.

git clone --single-branch --branch release/2024.1 https://gitlab.com/flightgear/simgear.git simgear
git clone --single-branch --branch release/2024.1 https://gitlab.com/flightgear/flightgear.git flightgear
git clone --single-branch --branch release/2024.1 https://gitlab.com/flightgear/fgdata.git fgdata

Building 2024.1

Once the code is loaded we can build. Editing and re-building can proceed without need to re-fetch the source. Using a git pull command can be use in each repository to keep up to date.

The general technique is to make a separate empty build directory, use cmake to configure and then compile and link. This avoids cluttering up the source directories with build files. Also, you can have several different configurations with the same source: fgbuild-release, fgbuild-debug, fgbuild-test, etc.

mkdir fgbuild
mkdir sgbuild
mkdir install
cd $HOME/fg2024.1/sgbuild
cmake ../simgear -DCMAKE_INSTALL_PREFIX=$HOME/fg2024.1/install -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
make install
cd $HOME/fg2024.1/fgbuild
cmake ../flightgear -DCMAKE_INSTALL_PREFIX=$HOME/fg2024.1/install -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
make install

FlightGear should now be installed in the local install directory. The fgdata files are automagically found in the local fgdata directory at the same level as the source directories.

export PATH=$HOME/fg2024.1/install/bin:$PATH

Next development version 2024.2

This version is for development of new features beyond the frozen features in 2024.1. This is the version where new ideas are developed for a future release. Join the FlightGear development team. Discuss changes with core developers on the developer mailing list. Depending on the state of development, this version may have bugs, may not work, or even may not compile.

Make sure that the required packages listed above beyond those needed for 2024.1 have been installed.

The big addition is that this version uses a local build of the OpenSceneGraph package. So there is an additional build directory for OpenSceneGraph.

Note also that we download the full Flightgear repository rather than a single branch as we did for 2024.1. This means that the full range of git commands such as switching branches are available.

mkdir $HOME/fg2024.2
cd $HOME/fg2024.2

Use the git repository

git clone https://gitlab.com/flightgear/openscenegraph.git openscenegraph
git clone https://gitlab.com/flightgear/simgear.git simgear
git clone https://gitlab.com/flightgear/flightgear.git flightgear
git clone https://gitlab.com/flightgear/fgdata.git fgdata

Building 2024.2

mkdir osgbuild
mkdir fgbuild
mkdir sgbuild
mkdir install

Note that we tell simgear where to find the newly constructed OpenSceneGraph. If you also loaded the fedora distribution of OpenSceneGraph to support building 2024.1 above, there is no conflict as we explictly tell simgear where to look.

cd $HOME/fg2024.2/osgbuild
cmake ../openscenegraph -DCMAKE_INSTALL_PREFIX=$HOME/fg2024.2/install -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
make install
cd $HOME/fg2024.2/sgbuild
cmake ../simgear -D OSG_INCLUDE_DIR=$HOME/fg2024/install/include -DCMAKE_INSTALL_PREFIX=$HOME/fg2024.2/install -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
make install
cd $HOME/fg2024.2/fgbuild
cmake ../flightgear -DCMAKE_INSTALL_PREFIX=$HOME/fg2024.2/install -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
make install
export PATH=$HOME/fg2024.2/install/bin:$PATH

Various tools

The examples above use low level tools such as tar and make to build the system. Higher level tools can also be used depending on user preference.

cmake

cmake --build can be used in place of make. The effect and level of effort are similar. If the developer is familiar with cmake and wishes to use the level of command there is no problem replacing make with cmake for this development.

Download_and_compile.sh

As mentioned above, the download_and_compile.sh command is used by developers on apt-based Linux systems to automate parts of the development process.

The single script merges all aspects of the devlelopment given above. In particular, the script has lists of system package dependencies that are automatically checked, loaded, or updated as needed. However this behaviour is closely linked to details of the apt command suite. Users on dnf-based systems such as Fedora, or redhat cannot use this.

If desired, the script can be used for parts of the development process on Fedora by omitting the system-package checks performed by apt. For example, the script uses git to automatically pull updates for the various parts of Flightgear from the repositories.

To use, load the system packages listed above with dnf and then do something like this:

mkdir $HOME/fg2024
cd $HOME/fg2024
git clone https://gitlab.com/flightgear/fgmeta.git fgmeta
fgmeta/download_and_compile.sh -p n FGFS

The -p n arg tells the script to NOT use apt to check, update, or fetch packages. Once the required packages are loaded from the Fedora repositories normal dnf upgrade commands will update the needed packages along with the rest of your system.

A detailed help message is available with

fgmeta/download_and_compile.sh --help

With no additional arguments as in the example above, the script will build 2024.2/next. To build 2024.1:

fgmeta/download_and_compile.sh -s -p n FGFS

Use of the download_and_compile.sh script has pros and cons.

If one is developing on both Fedora and other apt-based systems such as Ubuntu or Raspberry Pi, then using a common tool suite may be an advantage.

On the other hand, the script builds a somewhat complex directory structure and may do additional work not needed at various steps in your particular process. If you prefer a fully automated single tool, then the script may be desirable for you. If you prefer lower-level finer grained control of the process, using the separate commands my be preferred.