Manual Compilation on Ubuntu Linux

From FlightGear wiki
Jump to navigation Jump to search
WIP.png Work in progress
This article or section will be worked on in the upcoming hours or days.
See history for the latest developments.

Disclaimer

This is work in progress. Please do not follow this instructions yet and do not link to this page from more general instructions (see right below).

I actually try out the instructions I write on fresh installs of all four relevant system. This takes some time. Expect this page to be "released" within 2 or 3 weeks, that is by mid february 2010. I will then also link to it from other relevant pages.

1rightarrow.png See Building_FlightGear_-_Linux for the main article about this subject.

This section describes how to build the current developer (git) version of FlightGear on an Ubuntu Linux System.

If you are not an Ubuntu user you will find more generic instructions on building Flightgear on Linux in Building FlightGear - Linux.

As an Ubuntu user I also suggest you consider using the automated build script as described in Scripted Compilation on Linux Debian/Ubuntu before you start following this instructions.


Introduction

Ubuntu binary packages

Ubuntu offers binary packages of FlightGear that can be installed from the Software Center in your main application menu. Unfortunatelly, these packages contain a rather obsolete version of Flightgear. This instuctions describe how to obtain and compile the current developer version of FlightGear. Please remember that using the developer version has both advantages and disadvantages. While great new features are often present in this version months before they are incorporated into the next official release, some things might also occasionally be broken in the developer version. It might even happen every now and then that the sources you obtain from git might not compile at all and you will have to try again a couple of days later. If you are experiencing problems compiling or using the developer version please keep that in mind.

These instructions are tested on both the current release (10.10) and the last LTS release (10.4) of Ubuntu, both in their 64 bit and 32 bit incarnations. If you are still using an older version I suggest you consider upgrading your system.

To be able to follow these Instructions you should have opened a Terminal before and you should have some very basic knowledge of the Linux command line. It you know how to navigate between directories and how to create a new subdirectory this should be enough.

Requirements

Removal of Ubuntu package

In case you have installed the binary FlightGear packages provided by Ubuntu I suggest you remove them before moving on to your own compilation. While it is theoretically no problem to have several versions of flightgear installed at different locations on your system if you know what you're doing, this often causes strange problems for beginners. You can remove the Ubuntu packages using the Software Center, but I suggest to get you into the right mood for later you start using the command line now and enter:

  sudo apt-get remove flightgear simgear openscenegraph 

Installing the dependencies

  sudo apt-get update
  sudo apt-get install git-core cvs build-essential cmake automake libboost-dev
  sudo apt-get install libfreetype6-dev libpng-dev libjpeg-dev libtiff-dev libgif-dev libopenal-dev
  sudo apt-get install libxml2-dev libcurl4-openssl-dev libx11-dev libgl1-mesa-dev
  sudo apt-get install libalut-dev libplib-dev

Obtaining and Building the Sources

Creating a build directory

I suggest you create some folder off your home where you download the sources of FlightGear and its dependencies to.

  mkdir build
  cd build

Checking out the sources

Now obtain the sources of simgear and flightgear. You can skip over the first line, since we will use openscenegraph from the ubuntu repository. The line is kept here for reference.

svn co http://svn.openscenegraph.org/osg/OpenSceneGraph/trunk osg
git clone git://git.code.sf.net/p/flightgear/simgear/ simgear
git clone git://git.code.sf.net/p/flightgear/flightgear/ simgear

The atlas sources are not hosted with git. The developers use cvs instead. The cvs login command will ask you for a password. Just press enter (empty password) to go on.

  cvs -d:pserver:anonymous@atlas.cvs.sourceforge.net:/cvsroot/atlas login
  cvs -z3 -d:pserver:anonymous@atlas.cvs.sourceforge.net:/cvsroot/atlas co Atlas

If you are not suffering from lack of harddisk space you do not have to remove the source folders after you are done installing everything. If you keep the source folders you can save a lot of time and bandwidth next time you want to update your installation of FlightGear. To upgrade the state of the source directories to the most recent, enter each of the 3 git source folders and type "git pull". Only changes since the last time you cloned or upgraded will be fetched from the server. For the atlas entering "cvs co" from within the source directory will accompish the same.

Creating a directory for the installed components

You can install FlightGear and all the dependencies that you have compiled yourself into a common subfolder of /opt. This makes it easier to remove everything flightgear related later by just deleting that single folder. If you want to do this, create that directory now:

  sudo -p mkdir /opt/flightgear

Building OpenSceneGraph

As of February 2011 simgear can not be built against the latest git version of openscenegraph. You should use ubuntu's version of openscenegraph instead:

  sudo apt-get install libopenscenegraph-dev

Now skip ahead over the OSG build instructions to building the other packages :)

The build process of OSG is somewhat different from all the other packages. You should not build OSG in the source directory that you obtained but you should make a separate build directory right next to the sources:

  mkdir osg_build
  cd osg_build
  cmake -D CMAKE_BUILD_TYPE="Release" -D CMAKE_CXX_FLAGS="-O3 -march=native" CMAKE_C_FLAGS="-O3 -march=native" \
 	-D CMAKE_INSTALL_PREFIX:PATH="/usr" ../osg
  make -j2
  sudo make install
  cd ..

The -j2 option tells make to use two independend threads for compilation, thus speeding up the build process on multi-core systems. If you have a quad-core CPU, you might want to use -j4 instead, to utilize all four cores.

Building the other packages

For the other three packages the build process is basically the standard build process of most any unix software when building from a developer tree.

The -j2 option that is given to make below tells it to use two independend threads for compilation, thus speeding up the build process on multi-core systems. If you have a quad-core CPU, you might want to use -j4 instead, to utilize all four cores.

Build simgear, flightgear and atlas in this order:

  cd simgear
  sudo cmake -D CMAKE_INSTALL_PREFIX=/usr .
  make -j2
  sudo make install
  cd ..
  cd flightgear
  sudo cmake -D CMAKE_INSTALL_PREFIX=/usr .
  make -j2
  sudo make install
  cd ..


On 64 bits OS you could have compilation problems with libglut.so at make time, in this case type in the flightgear source dir :

sed -i 's/libglut.so/x86_64-linux-gnu\/libglut.so/' utils/fgpanel/CMakeFiles/fgpanel.dir/build.make

and restart

 make -j2
  sudo make install
  cd ..

Should works fine.

  cd atlas
  ./autogen.sh
  ./configure --prefix=/opt/flightgear
  make -j2
  sudo make install
  cd ..

In the end you might want to create symlinks ("shortcuts") of the installed executables to /usr/bin for easier terminal work :)

  sudo ln -s /opt/flightgear/bin/* /usr/bin/

Obtaining the Data Folder

I suggest you put the FlightGear data folder to /usr/share/flightgear, since this is the place where FlightGear looks for it by default with no $FG_ROOT environment variable set.

Obtaining fgdata for the first time

If you want to obtain the data folder for the first time you have to clone the current state of the git repository to your local computer. Open a new terminal and enter

cd /usr/share
sudo git clone git://git.code.sf.net/p/flightgear/fgdata/

Please be patient, this can take a long time.

Updating your local copy of fgdata that you obtained earlier

If you already have a local copy of the data directory that you got from the git repository in the way described above (this will not work with data directories downloaded any other way), you shoud not download the whole 4 or 5 GB again! This costs you a lot of time and the FlightGear server a lot of bandwidth! Instead you simply upgrade your local copy. To do this, open a new terminal and enter

  cd /usr/share/flightgear
  sudo git pull

Depending on how much changed on the server since you last obtained or updated your local copy this can be finished really quickly or it could take quite some time.

Be aware that, without some additional precautions, the update might fail if you changed any file in your local copy of the data folder since your last upgrade. If you are not helping to develop FlightGear you should therefor not edit any configuration files in you data folder. Make personal copies of any file you want to edit in your home folder and edit these instead.

Moving on ...

Flightgear is now installed on your system. You can test it by running

  fgfs

If you don't like working from a terminal you should try one of the available gui's for launching flightgear. I think the most common is fgrun, but personally I prefer FGo!.