TerraGear compilation - Ubuntu 14.04

From FlightGear wiki
Jump to navigation Jump to search

Some of us may still be running Ubuntu 14.04 LTS for various reasons. Building FlightGear from the repository is pretty easy with the download_and_compile.sh script. However, TerraGear will not build because 14.04 has an old GDAL library, v1.17. something, but we can work around that.[1]

Background

A year ago, July 16, 2016, the minimum version of GDAL was increased to v2.0.0 and the code was adapted to the new API. What those of us on Ubuntu 14.04 have had to do was to reset our TerraGear to the previous commit before this one and TerraGear would compile just fine. The problems arose when other fixes were needed because of changes in FlightGear and SimGear, so here we are...

How to proceed

Note  You must have an existing TerraGear repository managed by the download_and_compile.sh script before doing all this!

1. Get into our TerraGear repository

  cd ~/flightgear-dev/next/terragear

2. Make sure we are on the TerraGear scenery/ws2.0 branch

  git checkout scenery/ws2.0

3. Make sure we have done the reset

  git reset --hard 082ee9b82f15c8067183925a2ce48da817fa3748

4. Create and checkout a new branch for us to use

  git checkout -b oldgdal scenery/ws2.0

5. Now it is time to go cherry-picking

  git cherry-pick 0bb5df8d4d9e67a99b2afe27f53d90592ac97674
  git cherry-pick ac460f92259629d222aee2411319327c736fe967
  git cherry-pick 8f48b13f096e6bfe6245e3f000e82a8af09801e8
  git cherry-pick 73dff25ca1b20f975e967bfe9395a2729d4bbee7
  git cherry-pick 4c8455c0eeb65d0d30702ca48d540fed90376dd8
  git cherry-pick 1e32e9bccb64c6e0836f0bd1afb33221fa8976ec
  git cherry-pick cf5fcfc6c05d5e76918bb5c9e2d371a1e1d0fe3a
  git cherry-pick 95a34ae32abe60af89c2aace6bb28a65279d7e1c
Note  If you've modified your download_and_compile.sh script to force the above mentioned reset we will be commenting that out in the next step. If you mess up or otherwise reset in this branch, you have to cherry-pick again so do not do that! ;)

6. We need to edit download_and_compile.sh to add another round of cmake when we reconfigure TerraGear. This has something to do with CGAL and resetting the CXX_FLAGS. To build TerraGear with the new SimGear, we must add a flag to use c++11. This needs to be done when we configure which is where the CXX_FLAGS come into play so we will kill two birds in this step. Adding the flag and doing the double cmake round.

7. Load download_and_compile.sh into your editor.

7a. Near the top, around line 53, you will find these two lines

  SG_CMAKEARGS=""
  FG_CMAKEARGS=""

Add a new line to them so they look like this

  SG_CMAKEARGS=""
  FG_CMAKEARGS=""
  TG_CMAKEARGS="-DCMAKE_CXX_FLAGS=-std=c++11"

7b. Go down to your TerraGear build section and edit it to look like this. This will add 13 lines.

  TG_INSTALL_DIR=terragear
  INSTALL_DIR_TG=$INSTALL_DIR/$TG_INSTALL_DIR
  cd "$CBD"
  if [[ "$(declare -p WHATTOBUILD)" =~ '['([0-9]+)']="TERRAGEAR"' ]]; then
    echo "****************************************" | tee -a $LOGFILE
    echo "*************** TERRAGEAR **************" | tee -a $LOGFILE
    echo "****************************************" | tee -a $LOGFILE
  
    mkdir -p "terragear"
    cd "$CBD"/terragear
    _gitDownload https://git.code.sf.net/p/flightgear/terragear
    _gitUpdate scenery/ws2.0
  #################################################################
  # remove the next line when the OS has updated to GDAL >= 2.0.0 #
  # OR we have worked around the problem of having an old GDAL    #
  #################################################################
  #git reset --hard 082ee9b82f15c8067183925a2ce48da817fa3748
  
    if [ "$RECONFIGURE" = "y" ]; then
      cd "$CBD"
      mkdir -p build/terragear
      cd "$CBD"/build/terragear
      rm -f CMakeCache.txt
      echo " ** 1st CMAKE execution" | tee -a $LOGFILE
      "$CMAKE" -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
            -DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_DIR_TG" \
            -DCMAKE_PREFIX_PATH="$INSTALL_DIR_SIMGEAR;$INSTALL_DIR_CGAL" \
            $TG_CMAKEARGS \
            ../../terragear/ 2>&1 | tee -a $LOGFILE
      echo " ** 2nd CMAKE execution" | tee -a $LOGFILE
      "$CMAKE" -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
            -DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_DIR_TG" \
            -DCMAKE_PREFIX_PATH="$INSTALL_DIR_SIMGEAR;$INSTALL_DIR_CGAL" \
            $TG_CMAKEARGS \
            ../../terragear/ 2>&1 | tee -a $LOGFILE
    fi
  
    _make terragear
  
    cd "$CBD"
    echo "#!/bin/sh" > run_tg-construct.sh
    echo "cd $(dirname $0)" >> run_tg-construct.sh
    echo "cd install/terragear/bin" >> run_tg-construct.sh
    echo "export LD_LIBRARY_PATH=$INSTALL_DIR_SIMGEAR/lib" >> run_tg-construct.sh
    echo "./tg-construct \$@" >> run_tg-construct.sh
  
    echo "#!/bin/sh" > run_ogr-decode.sh
    echo "cd $(dirname $0)" >> run_ogr-decode.sh
    echo "cd install/terragear/bin" >> run_ogr-decode.sh
    echo "export LD_LIBRARY_PATH=$INSTALL_DIR_SIMGEAR/lib" >> run_ogr-decode.sh
    echo "./ogr-decode \$@" >> run_ogr-decode.sh
  
    echo "#!/bin/sh" > run_genapts850.sh
    echo "cd $(dirname $0)" >> run_genapts850.sh
    echo "cd install/terragear/bin" >> run_genapts850.sh
    echo "export LD_LIBRARY_PATH=$INSTALL_DIR_SIMGEAR/lib" >> run_genapts850.sh
    echo "./genapts850 \$@" >> run_genapts850.sh
  fi
  _logSep

7c. Save the changes and exit your editor.

8. Now we can finally build TerraGear using the download_and_compile.sh script.

The key, here, is to not download anything to update TerraGear. -d n prevents the TerraGear repository from being downloaded and/or updated. We will have to manage updates manually for now.

  ~/path_to_your/download_and_compile.sh -p n -d n -j 1 TERRAGEAR

That should do it. When download_and_compile.sh finishes, you should have a nice shiny set of TerraGear tools that you can play with building scenery. Remember, this uses your old GDAL v1.17 so none of the newer code specific to GDAL stuff will be able to be used. Future updates to this TerraGear will also have to be cherry-picked or hand-written.

References

  1. wkitty42  (Jul 1st, 2017).  Terragear compilation - Ubuntu 14.04 .