User:Daemonburrito/Building FlightGear - Linux

From FlightGear wiki
Jump to navigation Jump to 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. You will end up with a tree like this:

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.

Getting and compiling SimGear

Step 1:

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

$ git clone git://gitorious.org/fg/simgear.git

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

$ 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:

$ cd simgear
$ cmake .

Note that if you don't want to install simgear globally on the system but in a specific directory, you can do so by adding -DCMAKE_INSTALL_PREFIX==/path/to/your/fgInstallation to the cmake command

Step 3:

Compile and install SimGear by doing:

$ 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

Getting and compiling FlightGear

Step 1:

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

$ 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:

$ cd flightgear
$ ./autogen.sh
$ ./configure

Note that if you don't want to install simgear globally on the system but in a specific directory, you can do so by adding --prefix=/path/to/your/fgInstallation to the ./configure command. If you didn't install OSG globally or in the same prefix as SimGear and FlightGear, you have to pass the OSG directory to the configure-command like this:

$ ./configure --prefix=/path/to/fgInstallation --with-osg=/path/to/osg/installation --enable-osgviewer

In this case you have to tell your system where to find the OSG libraries before you can run flightgear:

$ export LD_LIBRARY_PATH=/path/to/osgInstallation/lib:$LD_LIBRARY_PATH

Step 3:

Now you can compile and install Flightgear by:

$ make; make install

Step 4:

Clone the data directory:

$ 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:

$ git clone git://mapserver.flightgear.org/fgdata

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

And install it in (or as) /usr/local/share/FlightGear

$ mv fgdata /usr/local/share/flightgear