Building TerraGear in Ubuntu 910 (32- or 64-bit)

From FlightGear wiki
Jump to navigation Jump to search
This article or section contains out-of-date information

Please help improve this article by updating it. There may be additional information on the talk page.

This tutorial is very outdated. The described process will not work anymore. Please use the instructions in Building TerraGear for now.

Note: This tutorial also works for OSX 10.5.8 (intel) and VBox 3.1.2r56127 but does not describe how to install VBox/Ubuntu on your mac.

Automatic Installation

If you are familiar with "download_and_compile.sh" script from Brisa you can download this script: http://clement.delhamaide.free.fr/download_and_compile_tg.sh This script is similar to Brisa's script (only usable for Debian/Ubuntu/Mint...). This script will install TerraGear (last version) and TerraGear GUI.

How to use it ? sh terragear_download_and_compile.sh -j 2 ALL

-j 2 option is for Dual Core, you can tune it as you want. (personally I have a Quad Core and I use -j 12 but I have to accept no to use my aircraft during compilation ;)

Need some help? Browse the dedicated forum's topic: http://forum.flightgear.org/viewtopic.php?f=20&t=14849

Basic Install

1. Start with a clean new installation of Ubuntu 910. Do not update the system after installation with Package Manager or other "Automatic Update Tools". Skip all updates (important!).

2. Install the basic packages for git access and development:

       * sudo apt-get install git-core curl automake g++ gcc

3. Make a new directory where you download and install the proper packages. You need also to prepare a directory "newmat11" to extract the archive you get from following link. gpc232 will extract in a directory itself.

4. Download the files inside the new created directories:

       * http://www.robertnz.net/ftp/newmat11.tar.gz
       * ftp://ftp.cs.man.ac.uk/pub/toby/gpc/gpc232.zip
       * git clone http://mapserver.flightgear.org/git/simgear-cs/
       * git clone http://mapserver.flightgear.org/git/terragear/

5. Before proceed to compile the main packages, we must understand that terragear depends from simgear-cs, and this last one has many dependencies to satisfy.

       * Install libplib-dev (1.8.5-4), libboost1.38-dev, glutg3-dev, libglut3-dev, libjpeg62-dev and xorg-dev via package manager

6. As previous step to compile simgear-cs, don't forget install the next packages:

       * sudo apt-get install libopenal-dev libalut-dev openscenegraph zlib1g-dev libopenscenegraph-dev

7. Goto to the directory simgear-cs to start the compilation. Remember that when we download source code with a cvs software as git or svn we need to

 generate the configure file:
       * ./autogen.sh
   The configure file is now created.
       * ./configure --with-jpeg-factory
       * make
       * sudo make install

8. To follow, we must satisfy 2 more dependencies: gpc and newmat. Unpackage those files and inside each directory:

   a) GPC:
       - Copy and paste the next lines and create a new empty file with the name "Makefile"
       - Replace "spaces" with tabs in your file and watch out for proper returns/end of line to get a working Makefile:
       
       
       # Unix/Linux makefile for GPC 2.32
       #
       # Riley Rainey  (riley.rainey@websimulations.com)
       CFLAGS = -O -g
       libgenpolyclip.a: gpc.o
               rm -f $@
               ar cr $@ $<
               ranlib $@
       clean:
               rm -f libgenpolyclip.a *.o core *~
       install: libgenpolyclip.a
               -mkdir -p /usr/local/lib
               -mkdir -p /usr/local/include
               install libgenpolyclip.a /usr/local/lib/libgenpolyclip.a
               install gpc.h /usr/local/include/gpc.h
       - Modify the file gpc.h, searching for "GPC_EPSILON (DBL_EPSILON)" and replace with "GPC_EPSILON (0.000001)"
       - And -obviously- make and sudo make install.... Done!!!
   b) NEWMAT:
       * make -f nm_gnu.mak
       * sudo cp libnewmat.a /usr/local/lib
       * sudo mkdir /usr/local/include/newmat
       * sudo cp *.h /usr/local/include/newmat
               
   After that, inside of the directory terragear:
       * ./autogen.sh
       * ./configure (see also option below)
       * Option: With gdal/OGR support
       * sudo apt-get install libgdal1-dev libogdi3.2-dev
       * run "./configure --with-gdal=/usr/bin/gdal-config"
       Finally:
       * make
       * sudo make install
       Before you run some terragear tools like fgfs-construct:
       * chmod -R 777 /usr/local/share/TerraGear/default_priorities.txt
       * chmod -R 777 /usr/local/share/TerraGear/usgsmap.txt

Optional steps

10. If we wish use the photo command and insert images inside our scenery, we need the chop.pl command:

       * sudo gedit /usr/local/bin/chop.pl:
   Copy and paste the follow code:
               #!/usr/bin/perl
               die "Usage: $0 file xdiv ydiv res\n" if $#ARGV != 3;
                   
               $file = shift;
               $xdiv = shift;
               $ydiv = shift;
               $res = shift;
               die "Must start with a .png file\n" if $file !~ /\.png$/;
               # extract image dimensions
               $info = `file $file`;
               $info =~ s/,//g;
               ($junk, $type, $junk, $junk, $width, $junk, $height, $junk)
                   = split(' ', $info, 8);
               print "$width - $height\n";
               $basename = $file;
               $basename =~ s/\.png$//;
               # convert source image to pnm
               `pngtopnm $basename.png > $basename.pnm`;
               $dx = $width / $xdiv;
               $dy = $height / $ydiv;
               for ( $j = 0; $j < $ydiv; $j++ ) {
                   for ( $i = 0; $i < $xdiv; $i++ ) {
                       print "Paso $i $j\n";
                       $x = $dx * $i;
                       $y = $height - $dy * ($j + 1);
                       $outputpnm = sprintf("$basename%X%X.pnm", $i, $j);
                       $outputsgi = sprintf("$basename%X%X.sgi", $i, $j);
                       $outputrgb = sprintf("$basename%X%X.rgb", $i, $j);
                	printf "Cutting files...\n";
                       printf "pnmcut $x $y $dx $dy $basename.pnm | pnmscale -xysize $res $res > $outputpnm\n";
                       `pnmcut $x $y $dx $dy $basename.pnm | pnmscale -xsize $res -ysize $res > $outputpnm`;
                       printf "Converting files...\n";
                       `convert $outputpnm $outputsgi`;
                       printf "Renaming files...\n";
                       rename($outputsgi, $outputrgb);
                       unlink($outputpnm);
                   }
               }
   Save the file.
   Install those additional packages which allows image manipulation:
       * sudo apt-get install imagemagick netpbm

11. Install QGIS for scenery edit.

       * sudo gedit /etc/apt/source.list
   Add to the bottom:
               deb http://ppa.launchpad.net/qgis/ubuntu hardy main
   Don't forget:
       * sudo apt-get update
       * sudo apt-get install qgis qgis-plugin-grass