User:Daemonburrito/Building FlightGear - Linux

From FlightGear wiki
Jump to: navigation, search

Compiling

If you're compiling Flightgear, you are likely to attempt building the latest revision. It is unlikely that a Linux distro will have a version of OpenSceneGraph recent enough for the latest Flightgear. To make the process of building dependencies like OpenSceneGraph from source easier, these instructions will assume that you will be installing to a custom "prefix"; a tree separate from root (/usr/lib).

This is advisable for the following reasons:

  • Builds can fail in mysterious ways if leftovers from older versions remain (common cause of build failures). You can safely delete your tree, without needing root.
  • If you're developing Flightgear, you are likely to need several variants available (e.g., "HEAD", Debug/Release).

These instructions will use a Bash variable called "$PREFIX". You can assign this variable at the beginning to use the commands verbatim, or you can substitute your path by hand.

Example: Setting $PREFIX

$ export PREFIX="/home/me/projects/fg"

You can even use your "project" directory as the prefix. To do this cleanly, make a src/ directory under the project directory. Download the git repositories into this directory. If you follow the rest of the instructions with $PREFIX=$HOME/projects/flightgear, you will end up with a tree like this (osg* include directories omitted for brevity):

~/projects $ tree -L 2 -d flightgear
flightgear
├── bin
├── include
│   ├── OpenThreads
│   ├── osg
│   └── simgear
├── lib
│   ├── FlightGear -> ../src/fgdata
│   └── x86_64-linux-gnu
├── lib64
│   ├── osgPlugins-3.2.0
│   └── pkgconfig
├── share
│   ├── flightgear -> ../src/fgdata
│   └── man
└── src
    ├── build.flightgear
    ├── build.osg
    ├── build.simgear
    ├── fgdata
    ├── flightgear
    ├── OpenSceneGraph
    └── simgear

CMake

Flightgear, Simgear, and OpenSceneGraph now use cmake. See the CMake wiki for additional documentation.

CMake allows users to create "out-of-source" builds, which means build files are created in a separate directory, and many variants can be maintained. To use out-of-source builds, simply create a new directory and pass the path to source to cmake.

Example: "out-of-source" build with CMake

simgear $ mkdir ../build.simgear
simgear $ cd ../build.simgear
build.simgear $ cmake ../simgear

ccmake

CMake build configuration files (CMakeCache.txt) are designed to be edited and generated. A GUI has been baked in since the beginning of the CMake project, which allows editing of configuration settings (like configure parameters).

For Ubuntu, the package cmake-curses-gui needs to be install to use the ccmake GUI.

Installation with CMake

After CMake has run, you can make && make install.

OpenSceneGraph

Full article: OpenSceneGraph

Using the build.* convention is advised.

~/projects/flightgear/src $ svn checkout http://svn.openscenegraph.org/osg/OpenSceneGraph/tags/OpenSceneGraph-3.2.0 OpenSceneGraph
~/projects/flightgear/src $ mkdir build.osg
~/projects/flightgear/src $ cd build.osg
~/projects/flightgear/src/build.osg $ cmake ../OpenSceneGraph -DCMAKE_INSTALL_PATH=$PREFIX
~/projects/flightgear/src/build.osg $ make && make install

You can change build settings by editing build.osg/CMakeCache.txt or by running ccmake.

SimGear

SimGear is hosted on Gitorious: https://gitorious.org/fg/simgear

Step 1:

Clone the SimGear git repository and set it up to track the 'next' branch.

~/projects/flightgear/src $ git clone git://gitorious.org/fg/simgear.git

or if the git port is firewalled on you network, use the http transport

~/projects/flightgear/src $ git clone http://gitorious.org/fg/simgear.git

By default after cloning you should have a local next branch that tracks the master next branch. It can be updated it with git pull.

Step 2:

The source code will be downloaded into a directory called simgear.

Next, go into the directory and make preparations for the compilation:

~/projects/flightgear/src $ mkdir build.simgear
~/projects/flightgear/src $ cd build.simgear
~/projects/flightgear/src/build.simgear $ cmake ../simgear -DCMAKE_INSTALL_PATH=$PREFIX -DCMAKE_PREFIX_PATH=$PREFIX

You can change build settings by editing build.osg/CMakeCache.txt or by running ccmake.

Step 3:

Compile and install SimGear by doing:

~/projects/flightgear/src/build.simgear $ make && make install

Note: With gcc 4.2 or later,on some platforms, you can get compiling errors about alc.h like: "'<anonymous>' has incomplete type". Take a look at http://bugs.gentoo.org/166723.

FlightGear

Step 1:

Clone the FlightGear git repository and set it up to track the 'next' branch.

~/projects/flightgear/src $ git clone git://gitorious.org/fg/flightgear.git

By default after cloning you should have a local next branch that tracks the master next branch. It can be updated it with git pull.

Step 2:

Next, go into the folder and make preparations for the compilation:

~/projects/flightgear/src $ mkdir build.flightgear
~/projects/flightgear/src $ cd build.flightgear
~/projects/flightgear/src/build.flightgear $ cmake ../flightgear -DCMAKE_INSTALL_PATH=$PREFIX -DCMAKE_PREFIX_PATH=$PREFIX

You can change build settings by editing build.osg/CMakeCache.txt or by running ccmake.

Now you can compile and install Flightgear by:

~/projects/flightgear/src/build.flightgear $ make && make install

fgdata

Clone the data directory:

~/projects/flightgear/src $ git clone git://gitorious.org/fg/fgdata.git

The data directory is large (almost 2.5GB) so it will take considerable time to download. There mirror of fgdata that might be faster to download from:

~/projects/flightgear/src $ git clone git://mapserver.flightgear.org/fgdata

The mirror is synchronized with the master so either will do.

Symlink it to the expected location. Currently, it's $PREFIX/lib. Previously, it has been $PREFIX/share.

$ cd $PREFIX/lib
$ ln -s ../src/fgdata FlightGear