Building FlightGear - Linux

From FlightGear wiki
Jump to navigation Jump to search

1rightarrow.png See Building Flightgear for the main article about this subject.

This section describes how to build FlightGear on Linux system.

Compiling FlightGear is not a task for novice users. Thus, if you're a beginner (we all were once) on a platform which binaries are available for, we recommend postponing this task and just starting with the binary distribution to get you flying.

openSUSE also provides binary packages of the latest development version, which are continuously updated. Follow this link to select your openSUSE version and install, or manually add games:FlightGear:Unstable to your YaST Software Repositories.

For Ubuntu, there is a PPA that provides the latest development version of FlightGear and SimGear and a recent version of FlightGear data. See this page for more info. To add the PPA, run sudo apt-add-repository ppa:saiarcot895/flightgear-edge.

Or if you develop on Ubuntu or Debian, consider trying the script described in Scripted Compilation on Linux Debian/Ubuntu.

Distro-specific instructions

Debian/Ubuntu

Gentoo

CentOS

CentOS users can follow these instructions to build FlightGear on CentOS 8.

Requirements

Note  as of 12/2017, people may have to build using at least OSG 3.4 due to some compilation issues -for details, refer to Howto:Building FlightGear without HiDPI support

Before you can compile FlightGear, you need to have the following installed on your computer:

C++ compiler

These are: c++, g++ found under the /usr/bin directory. You will also need to have the tools CMake installed.

GIT

See FlightGear and Git.

OpenGL support

More specifically, your system needs the support for hardware accelerated graphics. You can check for this by running the following in a command line:

$ glxinfo | grep direct

Note: To run the above command, you need to have the tool mesa-utils installed.

You should then see:

direct rendering: Yes

This means you are good to go as far as OpenGL support is concerned.

If you see:

direct rendering: No

Don't panic yet. This may just mean some required libraries for hardware accelerated graphic are missing. Go ahead and try installing plib 1.8.5 and its dependencies first. If you still get the above message, then you will need to do some googling and troubleshoot yourself.

Dependencies

FlightGear is dependent on quite a few number of libraries. You do not need to compile all of them yourself, but you will at least need to have their development version installed. For example, the development version for package plib1.8.5 is plib1.8.5-dev.

The dependency is summarized in the following tree. Please note that each library has its own dependencies, and most of these are not shown here.

  • FlightGear
    • OpenAL
    • SimGear
      • PLIB. Since March 2008, you will need version 1.8.5 - your distro probably supplies 1.8.4 still.
      • OpenSceneGraph (check link for compatible versions)
      • You also need the development files for several basic libraries to build the software, among them the following (the package names are for Debian and derivatives(?)):
        • libfreetype6-dev
        • libjpeg62-dev
        • libungif4-dev
        • libtiff4-dev
        • libpng12-dev
        • libxmu-dev
        • libxi-dev
        • zlib1g-dev
        • libglut3-dev

If you attack the above dependencies in the order listed below, you should be good:

  1. glut Most distributions include glut packages, although you may have to hunt for them. Make sure you install both the glut and glut-devel packages, otherwise FlightGear may be able to compile but won't run correctly.
  2. zlib Most distributions install the basic zlib libraries by default, but not the development portions. If you don't have zlib.h, you probably need to install the zlib-devel package for your distribution.
  3. plib Portability libraries and scene graph.
  4. OpenSceneGraph
  5. simgear Simulation support libraries. If you are building FlightGear from Git, you need the Git version of SimGear. If you have strange build errors, one of the first things to check is that you have an up-to-date version of SimGear built and installed.

Compiling

Definitions

The following environment variables must be set because they will be used in shell commands:

  • NR_JOBS: Number of jobs for parallel compilation. For example: NR_JOBS=$(/usr/bin/nproc).
  • FGFS_PREFIX: Prefix of the FlightGear installation. For example: FGFS_PREFIX=${HOME}/FlightGear. All the source code must be located under the directory ${FGFS_PREFIX}/src and the installation will be done under the directory ${FGFS_PREFIX} as ${FGFS_PREFIX}/bin, ${FGFS_PREFIX}/include, ${FGFS_PREFIX}/lib,...
  • cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo can be replaced by cmake -DCMAKE_BUILD_TYPE=Release for better performances.
  • FGFS_PREFIX_LIB: The default lib directory is different between RedHat and Debian based distributions. Usually on Debian based distributions
FGFS_PREFIX_LIB=${FGFS_PREFIX}/lib

Usually on RedHat based distributions

FGFS_PREFIX_LIB=${FGFS_PREFIX}/lib64

SimGear

The source code of SimGear can be provided:

  • as an official release that can be downloaded from here. The environment variable SIMGEAR_VERSION must be set to the relevant version of SimGear, for example SIMGEAR_VERSION=2019.1.1 and then using the following commands to extract the source code:
cd -- "${FGFS_PREFIX}/src/"
SIMGEAR_SRC=${FGFS_PREFIX}/src/simgear-${SIMGEAR_VERSION}
rm -Rf -- "${SIMGEAR_SRC}/"
tar axvf "${FGFS_PREFIX}/src/simgear-${SIMGEAR_VERSION}.tar.bz2"
  • as a clone of the SimGear Git repo by using the following commands:
cd -- "${FGFS_PREFIX}/src/"
git clone https://git.code.sf.net/p/flightgear/simgear flightgear-simgear
SIMGEAR_SRC=${FGFS_PREFIX}/src/flightgear-simgear
  • if you have already a clone of the SimGear Git repo, the local copy can be updated using the following commands:
cd -- "${FGFS_PREFIX}/src/"
SIMGEAR_SRC=${FGFS_PREFIX}/src/flightgear-simgear
pushd -- "${SIMGEAR_SRC}/"
git pull
popd

Now that the source code of SimGear is available under the directory ${SIMGEAR_SRC}, the build can be started using the following commands:

cd -- "${FGFS_PREFIX}/src/"
rm -Rf -- "${FGFS_PREFIX}/src/sg_build/"
mkdir -- "${FGFS_PREFIX}/src/sg_build/"
pushd -- "${FGFS_PREFIX}/src/sg_build/"
cmake "${SIMGEAR_SRC}" \
      -DCMAKE_BUILD_TYPE=RelWithDebInfo \
      -DCMAKE_INSTALL_PREFIX="${FGFS_PREFIX}" \
      -DCMAKE_VERBOSE_MAKEFILE=TRUE
make --jobs=${NR_JOBS}
make -- test
make -- install
popd
rm -Rf -- "${FGFS_PREFIX}/src/sg_build/"

FlightGear

The data for FlightGear can be provided:

  • as an official release that can be downloaded from here.
rm -f -- "${FGFS_PREFIX_LIB}/FlightGear"
rm -Rf -- "${FGFS_PREFIX_LIB}/FlightGear-${FLIGHTGEAR_VERSION}/"
mkdir --parents -- "${FGFS_PREFIX_LIB}/FlightGear-${FLIGHTGEAR_VERSION}/"
pushd -- "${FGFS_PREFIX_LIB}/FlightGear-${FLIGHTGEAR_VERSION}/"
tar axvf "${FGFS_PREFIX}/src/FlightGear-${FLIGHTGEAR_VERSION}-data.tar.bz2"
popd
pushd -- "${FGFS_PREFIX_LIB}/"
ln --symbolic -- "FlightGear-${FLIGHTGEAR_VERSION}/fgdata/" FlightGear
popd
  • as a clone of the FlightGear Git repo by using the following commands:
pushd -- "${FGFS_PREFIX_LIB}/"
git clone --depth 1 https://git.code.sf.net/p/flightgear/fgdata flightgear-fgdata
ln --symbolic -- "flightgear-fgdata/" FlightGear
popd
  • if you have already a clone of the FlightGear Git repo, the local copy can be updated using the following commands:
pushd -- "${FGFS_PREFIX_LIB}/flightgear-fgdata/"
git pull
popd

The source code of FlightGear can be provided:

  • as an official release that can be downloaded from here. The version of SimGear and FlightGear must match. The environment variable FLIGHTGEAR_VERSION must be set to the relevant version of FlightGear, for example FLIGHTGEAR_VERSION=2019.1.1 and then using the following commands to extract the source code:
cd -- "${FGFS_PREFIX}/src/"
FLIGHTGEAR_SRC=${FGFS_PREFIX}/src/flightgear-${FLIGHTGEAR_VERSION}
rm -Rf -- "${FLIGHTGEAR_SRC}/"
tar axvf "${FGFS_PREFIX}/src/flightgear-${FLIGHTGEAR_VERSION}.tar.bz2"
  • as a clone of the FlightGear Git repo by using the following commands:
cd -- "${FGFS_PREFIX}/src/"
git clone https://git.code.sf.net/p/flightgear/flightgear flightgear-flightgear
FLIGHTGEAR_SRC=${FGFS_PREFIX}/src/flightgear-flightgear
  • if you have already a clone of the FlightGear Git repo, the local copy can be updated using the following commands:
cd -- "${FGFS_PREFIX}/src/"
FLIGHTGEAR_SRC=${FGFS_PREFIX}/src/flightgear-flightgear
pushd -- "${FLIGHTGEAR_SRC}/"
git pull
popd

Now that the source code of FlightGear is available under the directory ${FLIGHTGEAR_SRC}, the build can be started using the following commands:

cd -- "${FGFS_PREFIX}/src/"
rm -Rf -- "${FGFS_PREFIX}/src/fg_build/"
mkdir -- "${FGFS_PREFIX}/src/fg_build/"
pushd -- "${FGFS_PREFIX}/src/fg_build/"
cmake "${FLIGHTGEAR_SRC}" \
      -DCMAKE_BUILD_TYPE=RelWithDebInfo \
      -DCMAKE_INSTALL_PREFIX="${FGFS_PREFIX}" \
      -DCMAKE_VERBOSE_MAKEFILE=TRUE \
      -DENABLE_FGQCANVAS=ON
make --jobs=${NR_JOBS}
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${FGFS_PREFIX_LIB}/
FG_ROOT=${FGFS_PREFIX_LIB}/FlightGear make --jobs=${NR_JOBS} -- test_suite
FG_ROOT=${FGFS_PREFIX_LIB}/FlightGear make -- test
make -- install
popd
rm -Rf -- "${FGFS_PREFIX}/src/fg_build/"

External links

Instructions

Important note for GIT users

As of latest development in GIT, only cmake is now required for building both SimGear and FlightGear. So if you build GIT (for what any reason) please don't try to use autogen.sh as it is removed from repository.

For detailed instructions, see page Building using cmake.