Scripted Compilation on Linux Debian/Ubuntu

From FlightGear wiki
Revision as of 07:33, 22 April 2019 by Rominet (Talk | contribs) (Rewording to avoid repetition)

Jump to: navigation, search is a Bash script that takes care of downloading and compiling FlightGear from the Git repositories with just one command execution[1] for both 32-bit and 64-bit Debian-based systems (Debian, Ubuntu, Devuan, Linux Mint, etc.). Pre-existing installed versions (if any) of FlightGear are not touched at all since the script downloads, builds and installs everything under the directory in which it is launched. You can choose between building all or only specific tools and applications. For RedHat-based systems such as Fedora and CentOS, you may want to check out CentOS.

By default, installs most dependencies with apt-get run under sudo.[2] Other dependencies, either because they aren't available in the standard APT repositories, or because it was explicitly requested using the non-option arguments of, are downloaded and compiled on the fly (this can be the case for PLIB, Simgear and OpenSceneGraph, for instance—depending on the arguments passed to

For hints on using a RPM-based distribution like CentOS, please see CentOS.

Please also see Superbuild.

Update Available

The latest version of can be obtained here, however there are advantages getting it from an FGMeta clone as explained here. Contents should be moved from there to this page; significant parts of what follows on this page haven't been updated recently.

Cut to the Chase: for the impatient

Beware: with the following, you are likely to encounter problems when cloning FGData: read just above.

cd  <your working directory for building FlightGear>
wget -O
chmod +x
mkdir -p stable
mkdir -p next
cd stable
../ -j$(nproc) -s
cd ../next
../ -j$(nproc) -p n
Note  With -j$(nproc) as above, the compilation will use all cores available on your processor, which can save several hours. If you want to use, say, 4 cores, replace -j$(nproc) with -j4.

Conversion of directory structure from earlier versions of

Earlier versions of the script used a different directory structure. If you used the earlier version, the new script includes a section that will convert the earlier structure to the current set of directories.

Disk Space Requirements

As of April 2019, building FlightGear requires about 11 Gigabytes of disk space. Note that this includes downloaded source code, build files and the large FGData repository (about 5 Gigabytes for that one).

List of compiled programs

The script is able to download and compile:

(Note that OpenRTI is just an optional dependency for HLA support. For the time being, you should be just fine building without it. Eventually, the idea is for HLA to replace the existing MP system and even increasingly distribute the FlightGear architecture such that more and more components can be more easily run in separate threads or even separate processes, possibly even on different machines. So this is going to be an important feature for professional users, using several computers and screens to create a comprehensive and immersive simulation environment.

At the moment, it's probably safe to say that HLA is only of interest to developers and people willing to play with experimental features.)

Each of the items listed above corresponds to a component in terminology. Components are written in uppercase. The list of supported ones is currently:

  • FGFS (this corresponds to FlightGear)
  • DATA (this corresponds to FGData)
  • PLIB
  • OSG (this corresponds to OpenSceneGraph)
  • FGO
  • FGX

The up-to-date list of components can be obtained by running: --help

What is the point of knowing this? Because you may pass component names to in order to tell it what you want to download, build and install. By default, only the three essential components SIMGEAR, FGFS and DATA are taken care of, which means that the command:

is equivalent to: SIMGEAR FGFS DATA

In case you want to do the same build with just OpenSceneGraph added, you can use: SIMGEAR FGFS DATA OSG

You get the idea. When several components are passed on the same command line, chooses a reasonable order for processing, so don't worry about that.

When building Next you may see build errors

Keeping in mind that this script compiles sometimes bleeding edge software, it can happen that what was successfully compiling last week, does not compile anymore today. Building the stable version should always work, unless there is a problem with the script.

That said, don't be too afraid of building the development version (called next): this is the one developers use all the time, so kindly asking on the flightgear-devel mailing list in case a problem popped up[3] should allow you to find good advice and get the problem quickly fixed, if it's a new one. Conversely, probably not many people (in 2019) build themselves the “stable” version of FlightGear. People who want the stable version can usually have it from their distribution, this is generally easier. On the other hand, those running typically want to build the latest code that FlightGear developers are working on; this is useful when you want to contribute feedback, code, aircraft or scenery based on recent technology, or just want to enjoy the latest features and bugs. ;-)


You can get from FGMeta. It is contained in the FGMeta repository, which is maintained by the FlightGear developers. Remember to update this script whenever a new FlightGear version is released, so that you'll be able to download the latest stable revision (of course, you can update it more often to benefit from bug fixes, it doesn't have to happen after a release).


To run, just save it in a directory called for example: ~/fgfs then execute it (no need to execute it as root).

Here is for example a sequence of commands to get the script from the master branch. You can replace master with next to get a later version of the script if one is available:

mkdir ~/fgfs
cd ~/fgfs
chmod 755

You have two options now: build the latest stable FlightGear release or build the current development version (bleeding edge). After building stable or the latest, if you need to build a different version, try the instructions for Avoiding multiple downloads of FGData on Linux.

Build the latest stable FlightGear release

When executing the script, use the "-s" option to build the latest stable release:

./ -s

Build the current FlightGear development version

When executing the script without any options, the latest development version is built.

Warning: The development version of FlightGear changes on an almost daily basis. It provides the latest features, but is not always guaranteed to work reliably. If you're unfamiliar with software testing, you may prefer to use the latest stable release.


Once the script is finished, you will successfully get FlightGear and FGRun installed in the ~/fgfs directory.

Launching FlightGear

When using Brisa's script, the two FG dependencies/libs are usually not installed system-wide, but in a custom location (that makes it possible, to easily use different OSG/SG/FG versions on a single system, i.e. for testing purposes - but also to have separate build trees (optimized/debug) ) - which is why you either need to set LD_LIBRARY_PATH or simply use Brisa's script to run everything (something like, which automatically sets up all environment variables according to your build settings).

To run your new git installation of FlightGear you have to launch the command under the same folder, for example:

cd ~/fgfs

Launching FGRun


For many users it's more comfortable having FlightGear launched by the graphical utility FGRun which is installed as well in the same folder. You have to launch the command, for example:

cd ~/fgfs

FGRun will save its settings in ~/.fltk/ you may want to save copies of the preferences customized for stable and next.

Launching FGo!


This is a graphical utility written in python, You have to launch the command, for example:

cd ~/fgfs

Remember that the first time you run it, you have to go to preferences and set the binary and FGData path (Do no set the working directory, you don't need it).

Additional programs

If you wish to get all the other programs, you need to launch the script adding the "ALL" option to the command line:

./ ALL

This, will also install FGCOM, FGComGui and Atlas

Launching FGCOM

FGCOM is the system used by FlightGear to simulate radio communications between users. Launch it using the command:

cd ~/fgfs

Launching TerraSync

Your FlightGear compilation comes with the TerraSync program too, so if you want to use it:

cd ~/fgfs
sh -S -p 5500 -d /folder/with/sceneries

Where: /folder/with/sceneries is the folder containing the sceneries data.

Then launch FGFS with the --fg-scenery=/folder/with/sceneries --atlas=socket,out,5,localhost,5500,udp option


Compilation errors

Here we are, no fear, if you wish to use programs from the cvs/svn/git repositories, you might face compilation errors that will prevent you to have a working copy of one or more of the programs provided by this script. What can be the causes that prevent us from successfully compiling? As far as I know those:

  1. Software developers introduce a new functionality with a new piece of code that prevents the compilation under your architecture, this can happen working with cvs/svn/git sources.
  2. The program refuses to compile because of a divergence in the libraries on which it depends. For example FlightGear might not compile because OSG has been modified, while OSG itself compiles fine, FG won't.
  3. One or more repositories are down and you can't get the library you need. (Both from cvs/svn/git or apt-get)

There is a simple solution to the above errors: wait and relaunch the script after some time (hours or days), if software developers repair or synchronize their code with the newly updated libraries (which generally happens eventually), your FlightGear will compile fine as if the previous error never took place.

Sometimes it happens that the script fails to compile only FGRun, FGCOM or atlas, if you then see the file it means that FlightGear installation was successful and you can safely run it.

OpenRTI undefined reference errors

Sometimes due to the way d&c build cleans up projects, linking errors might occur, this is the case with this error " undefined reference to xxx", sadly at this point either you need to patch the d&c script to clean OpenRTI with rm -f CMakeCache.txt && rm -rf CMakeFiles/, or just start from a clean environment, assuming you are in the parent project directory, you will need to issue this command to clean everything(except FGDATA):

rm -rf build/* install/simgear/ install/openrti/ install/flightgear/share/ install/flightgear/bin/

see this thread for more details (


The script by default (without any option) will only compile FlightGear and FGRun. To make it compile all, you need to launch the script with the ALL parameter. i.e.:

./ ALL

Compiling only one program

If you wish to recompile only one of the programs you can launch the script with one of the following parameters:

  • CMAKE (to compile and install only cmake)
  • PLIB (to compile and install only plib)
  • OSG (to compile and install only OpenSceneGraph)
  • SIMGEAR (to compile and install only Simgear)
  • FGFS (to compile and install only FlightGear)
  • DATA (to download / update only data files for FlightGear)
  • FGRUN (to compile and install only Fgrun)
  • TERRAGEAR (to compile and install only terragear!)
  • TERRAGEARGUI (to compile and install only terrageargui!)
  • OPENRADAR (to compile and install only OpenRadar!)
  • FGO (to compile and install only Fgo!)

Fast updating

There is a second parameter UPDATE that allows you to just update your installation. i.e.: This will only update FGFS


Compiling last stable versions (Experimental)

Even if the script fetches data and sources from bleeding edge developers repositories (which sometimes do not compile), you can still force the script to download latest known versions of the software that were compiling successfully by adding the -s option.

./ -s

How does it work? Inside the script there is a small list with latest known versions of successfully compiling revisions, it will download from svn/git those specific revisions, which have been found able to compile together.
Warning: If you run this option inside a folder where you previously compiled FGFS, it will probably fail to compile, you better run the script with this option inside an empty folder or a folder with the same FGFS version compiled previously.

Advanced options

  • Build a release version using -b Release option
  • Build a debug version for more complete bug reporting using -b RelWithDebInfo option (default)
  • Build a full debug version for very complete bug reporting using -b Debug option
  • Skip download of distro packages using -p n option
  • Skip compilation of programs using -c n option
  • Skip retrieving software updates using -d n option
  • Skip reconfigure (make clean) using -r n option

For example, if you are a developer and wish to quickly recompile and reinstall only your own modifications for FlightGear do this:

./ -p n -d n -r n  FGFS

this will only recompile modifications and reinstall them.

Multicore Acceleration

Using the option -j x (where x is the number of your CPU-Cores you wish to assign to the job) will speed up the whole compilation process considerably.

Disk usage

Having both compiled program, source code, and data from git requires some hard disk space: It will take something like 13 GB of space. If you don't have a fast machine, it will require several hours of compilation time.

Optimus technology

If your computer has a GPU with Optimus technology, you need a dedicated script in order to make FG running with the powerful GPU.

After having installed required tools (Bumblebee) you just need to run this command line in your FG installation directory (where you executed ./ :

sed  's|\./fgfs|optirun ./fgfs|' > && chmod +x

Now you can run FG with ./

the same is applied with the FGRun launcher :

sed  's|\./fgrun|optirun ./fgrun|' > && chmod +x

Remove warning message for DDS files

You can remove the warning message displayed when DDS files are parsed by SimGear by adding the following line just after cd "simgear" line :

	sed -i s/SG_ALERT,\ \"Image/SG_WARN,\ \"Image/g simgear/scene/model/ModelRegistry.cxx

See also

  • Other FlightGear build scripts can be found in FGMeta.
  • Another script for building FlightGear and all its dependencies in an automated fashion can be found here. The page seems a bit oldish, though (as of 2019).


  1. Due to technical problems on the SourceForge side, this is currently only true once you have an FGData clone. See here for details.
  2. This can be changed with options --package-manager and --sudo, or completely turned off with option -pn (see the output of --help for the list of available options).
  3. Don't forget in this case to precisely tell what you did and include the compilation_log.txt file written by