PDA

View Full Version : Build gdal/ogr with libkml and FileGDB support



Mack
31st May 2014, 06:00 AM
The Fedora gdal package doesn't support FileGDB because it's a proprietary format, though it is free as in beer, and is the de facto format for open gis data. libkml, the Google earth xml format, hasn't been maintained since F15.

Both are a nuisance to build. I just had to for an F20 update, and thought it might be useful to post how to do it at this moment.

I won't attempt to list the various devel and build packages you need. If you're reading this, you already know how to figure that out.

Build libkml:



svn checkout http://libkml.googlecode.com/svn/trunk/ libkml-read-only
cd libkml-read-only
./autogen.sh
patch -p1 < /path/to/libkml.diff
aclocal
automake --add-missing
./configure --prefix=/usr --libdir=/usr/lib64 --with-java-include-dir=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.60-2.4.7.0.fc20.x86_64/include
make -j$threads
sudo make install



The initial ./autogen.sh will throw a list of exceptions. It is just to create files (eg, configure) to patch.

The attached libkml.diff puts together several fixes I eventually found on the libkml site, ones that were suggested by the build tools, and a fix to a broken swig version test I noticed in configure.

If you are building 32 bit or your java is different, you need to modify the configure options.

"-j$threads" is sometimes funky. If you have trouble, drop it.

If there are compile errors, don't install them. Duh.

Build gdal/ogr:

There are instructions on the gdal wiki for building with FileGDB support. (http://trac.osgeo.org/gdal/wiki/FileGDB)

Before you get started you have to get the proprietary API.


Get a free account with esri (https://webaccounts.esri.com/cas/index.cfm/index.cfm?fuseaction=Registration.ShowForm)
Download FileGDB_API_1_2-64.tar.gz (or some such)
In /usr/local/lib64:
tar xzf FileGDB_API_1_2-64.tar.gz
Create /etc/ld.so.conf.d/esri-x86_64.conf containing the line

/usr/local/lib64/FileGDB_API/lib

ldconfig


Now to build gdal, either download the latest stable version gdal-1.11.0 from the gdal.org (http://trac.osgeo.org/gdal/wiki/DownloadSource) site,


wget http://download.osgeo.org/gdal/1.11.0/gdal-1.11.0.tar.gz

or get the latest


svn checkout https://svn.osgeo.org/gdal/trunk/gdal gdal

If you have Oracle java, configure can find it. If you have openjdk, it's easiest just to


ln -s /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.60-2.4.7.0.fc20.x86_64/jre/lib/amd64/server/libjvm.so /usr/lib64/

If you have a different version, you'll need to fix this symlink.

If you need WebP format, you have to work around a bug in configure. --with-webp=yes is ignored. Edit configure, adding

with_webp=yes
just below

WEBP_SETTING=no

If you need SWIG ruby bindings, before running configure,


export CPPFLAGS="-fPIC"

Now we're ready to go. I used


./configure --with-java=/usr/lib/jvm/java-openjdk/ --with-mdb=yes --with-python --prefix=/usr --libdir=/usr/lib64 --with-threads --with-ogdi --with-cfitsio --with-geotiff --with-libtiff --with-libz --with-netcdf --with-hdf4 --with-hdf5 --with-netcdf --with-geos --with-jasper --with-png --with-gif --with-odbc --with-sqlite3 --with-mysql --with-curl --with-perl --with-ruby --with-pcraster --with-liblzma=yes--with-webp=yes --with-xerces --with-freexl --with-xerces-lib='-lxerces-c' --with-xerces-inc=/usr/include/xercesc/ --enable-shared --with-libgrass=yes --with-grass=/usr/lib64/grass-6.4.3 --with-expat=yes --with-poppler=yes --with-armadillo=yes --with-fgdb=/usr/local/lib64/FileGDB_API --with-libkml=yes
make
sudo make install

No claim is made that these are the best possible options.

The libxml2 libraries are embedded in the FileGDB proprietary library. If you have them installed you get a warning about possible conflicts. I've never had any trouble. Again YMMV.

The output from configure is helpful in tracking down what devel packages you need. As a certified fussbudget, I've enabled everything I could find that is in the regular repositories. A more sensible approach is not to enable things that you don't need.