Linux: Getting a qualified GDAL library
Manual installation of OTB dependencies can easily be done under unix platforms, either directly by package managers (be sure to also install libraries headers, which are mandatory to build OTB) or by compiling from sources (follow the build instructions for each particular dependence).
However, special precautions are necessary concerning Gdal.
Gdal is a very rich data abstraction library, and there are many compilation time options in Gdal that will impact Gdal and therefore OTB libraries capabilities. There are also options and dependencies that could limit or prevent Orfeo ToolBox from working properly. On linux systems, there are a lot of Gdal binary packages with different configurations. It is therefore very important to know exactly your Gdal configuration before proceeding to the next step.
Here are the things to check:
- Gdal version (should be greater or equal to 1.10),
- Gdal library should not expose any Tiff or Geotiff symbol (otherwise it may cause crashes in Orfeo ToolBox),
- Gdal should support BigTiff (read or write Tiff files of more than 4 Gb).
How to check if your Gdal qualifies for Orfeo ToolBox?
If you already have a Gdal in your system (either from the official package manager of your distribution or from your own build), here is how to check if it qualifies for Orfeo ToolBox.
Gdal version can be checked using the following command:
$ gdal-config --version
If version is lower than 1.10.0, you should build or install an up-to-date Gdal library.
If you have several versions of Gdal installed in your system, be sure to run this command for the version you intend to. You can check this with:
$ which gdal-config
Next step is to check if the Gdal library leaks any Tiff or Geotiff symbol. First you need to locate gdal library. If it has been installed system wide, the library will most probably be located in /usr/lib. Otherwise, you need to find where is libgdal.so.
Once you found it, run:
$ nm -D libgdal.so | grep XTIFFOpen
This should show either nothing, or the following:
00000000004b1100 T gdal_XTIFFOpen
If the command outputs the following:
00000000004b1100 T XTIFFOpen
It means that your Gdal library leaks Tiff and Geotiff symbols. Depending on your system, this might cause random crashes in Orfeo ToolBox when reading or writing Tiff images. In this case it is advised to build or retrieve a Gdal library that does not exhibit this issue.
Last, it might be important for you to be able to read and write Tiff files of more than 4 Gb with Orfeo ToolBox. To check for BigTiff file support, choose an image on your computer and run:
$ gdal_translate -co "BIGTIFF=YES" my_image.png my_image.tif
If this fails, your Gdal library or the Tiff library it is linked to does not support BigTiff files. In this case it is advised to build or retrieve a Gdal library.
Building your own qualified Gdal
If do not yet have a Gdal library or suspect that the library you have will not qualify, you can build your own library. After downloading the latest version of gdal source code, run:
$ export GDAL_INSTALL_DIR=$HOME/local $ ./configure --prefix=$GDAL_INSTALL_DIR \ --with-geotiff=internal \ --with-rename-internal-libtiff-symbols=yes \ --with-rename-internal-libgeotiff-symbols=yes $ make install
The GDAL_INSTALL_DIR environment variable allows to choose where you will install your Gdal library. It is NOT advised to install it system wide. It is recommended to choose a dedicated directory in your home folder. The configuration options will ensure that Gdal will build internal Tiff and Geotiff libraries that supports BigTiff files, while renaming their symbols so that they will not be leaked outside of the library. Depending on your need, feel free to enable more Gdal configuration options.
Once this is done, be sure to update your environment variables:
$ export PATH=$PATH:$GDAL_INSTALL_DIR/bin $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GDAL_INSTALL_DIR/lib $ export GDAL_DATA=$GDAL_INSTALL_DIR/share/gdal
Also note that with this Gdal configuration, you will still need to have Tiff and Geotiff libraries and headers available on your system to build OTB (due to third parties requiring them). However, you can use the system packages for those.