Building FlightGear - Linux: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
Line 167: Line 167:
  ./configure --prefix=/path/to/fgInstallation --with-osg=/path/to/osg/installation --enable-osgviewer
  ./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:
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/fgInstallation/lib:$LD_LIBRARY_PATH
   export LD_LIBRARY_PATH=/path/to/osgInstallation/lib:$LD_LIBRARY_PATH


'''Step 3:'''
'''Step 3:'''

Revision as of 21:06, 1 May 2009

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.

Requirements

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

C++ compiler

These are: c++, cpp, gcc, g++ found under the /usr/bin directory. You will also need to have the tools autoconf and automake1.9 installed.

CVS

Yes, the program is called 'CVS'. This is used for downloading the latest set of source code. Windows developers may wish to see Using TortoiseCVS with FlightGear.

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.

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 CVS, you need the CVS 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.

APT-GET List

This is a list of all the apt-get commands I had to do while compiling FG, SG, and OSG on a mostly clean Ubuntu 64 system. It is a list of all the libraries you and your computer needs to compile FG, SG, OSG, and PLib. All you have to do is copy the full command, paste it in Terminal, enter your password, and it will download all the packages for you, and install them too. The full command is at the bottom, and I hope someone finds it useful :) sub-dependencies (dependencies of the dependencies) are not included as they are installed automatically by apt-get. If anyone sees something missing, please add it.

cvs - to get SG and FG
subversion - to get OSG
build-essential - to build (includes GCC, and other build tools)
cmake - OSG Uses this
libpng-dev - to enable FG to use PNG textures
libfreetype6-dev - fonts
libjpeg-dev
libungif4-dev
libtiff-dev
libxmu-dev
libxi-dev
libalut-dev - sound
libboost-dev - makes coding for some developers easier
automake - needed by ./autogen.sh files
autoconf - needed by ./autogen.sh files
libfltk1.1-dev - You will need this if you will be using FGRun


sudo apt-get install cvs subversion build-essential cmake libpng-dev libfreetype6-dev libjpeg-dev libungif4-dev libtiff-dev libxmu-dev libxi-dev
libalut-dev libboost-dev automake autoconf libfltk1.1-dev

Total size is about 230 MB, depending on what you already have from other applications.

This list might seem a bit short, but the sub-dependencies all add up :) The dependencies will be listed by apt-get when you use the command.

Compiling

Assuming you are root, do:

cd /usr/local/src

Note: When tracking a fast changing software like FlightGear/CVS it is highly advisable to install it in a separate directory. That way one can also easily build and reinstall without being root, which greatly reduces the risk of messing up one's system. To install in a directory of your choice add the --prefix argument to configure. E.g. ./configure --prefix=$HOME/FlightGear. I would recommend installing all of OSG, plib, SimGear and FlightGear with the same prefix.

Getting and compiling SimGear

Step 1:

Login to the cvs server and checkout the latest version of SimGear's source code with:

cvs -d :pserver:cvsguest@cvs.simgear.org:/var/cvs/SimGear-0.3 login
CVS passwd: guest

cvs -d :pserver:cvsguest@cvs.simgear.org:/var/cvs/SimGear-0.3 co source

Step 2:

Since all the source code will be downloaded into a directory called source, you will need to rename the directory into something more meaningful.

Rename the above directory by doing:

mv source simgear

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

cd simgear
./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

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:

To login to the cvs version and checkout the latest version of Flightgear's source code, use:

cvs -d :pserver:cvsguest@cvs.flightgear.org:/var/cvs/FlightGear-0.9 login
CVS passwd: guest

cvs -d :pserver:cvsguest@cvs.flightgear.org:/var/cvs/FlightGear-0.9 co source

A directory with the name source will then be created with all of Flightgear's source code downloaded into it.

Step 2:

To rename the above directory, use the following command:

mv source flightgear

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 are building the OSG-version of FlightGear and didn't install OSG globally, 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:

Get the data directory:

cvs -d :pserver:cvsguest@cvs.flightgear.org:/var/cvs/FlightGear-0.9 co data

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

mv data /usr/local/share/FlightGear

Ubuntu and Debian users

If you wish you can use the Scripted_Compilation_on_Linux_Debian/Ubuntu script to have Flightgear compiled in one shot under both Ubuntu and Debian systems.

External links

Instructions