Skip to content

Instantly share code, notes, and snippets.

@zhm
Last active February 28, 2022 17:11
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save zhm/2005158 to your computer and use it in GitHub Desktop.
Save zhm/2005158 to your computer and use it in GitHub Desktop.
Building GDAL 1.9 with ESRI FileGDB support on OS X Lion

Building GDAL 1.9.x with ESRI FileGDB support on OS X Lion

  • Download the SDK from ESRI's website http://resources.arcgis.com/content/geodatabases/10.0/file-gdb-api
  • Extract the SDK, and put the contents of the directory in a known location, I used ~/local/filegdb. Here's an example path to one of the files: ~/local/filegdb/lib/libFileGDBAPI.dylib
  • I use ~/local/filegdb so it can stay isolated in it's own place. You can put it anywhere, but the next few steps might be different.
  • Go into the directory containing the FileGDB SDK, e.g. ~/local/filegdb
  • ESRI built these dylib's using @rpath's, so to avoid needing to mess with DYLD_LIBRARY_PATH, I updated the @rpath's using install_name_tool. There might be a more elegant way to handle this. If so, comments are welcome!
  • Here are the commands I used to patch the dylibs, this is not required if you want to use DYLD_LIBRARY_PATH yourself:
    install_name_tool -id "$(pwd)/lib/libFileGDBAPI.dylib" ./lib/libFileGDBAPI.dylib
    install_name_tool -change "@rpath/libfgdbunixrtl.dylib" "$(pwd)/lib/libfgdbunixrtl.dylib" ./lib/libFileGDBAPI.dylib
    install_name_tool -id "$(pwd)/lib/libfgdbunixrtl.dylib" ./lib/libfgdbunixrtl.dylib
  • To verify the paths, use otool -L lib/libFileGDBAPI.dylib and otool -L lib/libfgdbunixrtl.dylib and make sure the paths are correct
  • We need to make some changes to the configure.in script for GDAL now, since the FileGDB config script hasn't yet been updated for the OSX FileGDB SDK
  • In the GDAL source root, edit the configure.in and replace it with:
  • In the GDAL source root, run ./autogen.sh to re-create the configure script
  • Now run the configure script:
    ./configure --with-fgdb="$HOME/local/filegdb"
  • The configure script has many options, here is the configure line I use for my custom build: https://gist.github.com/2005091, if you have other GDAL builds on your machine (e.g. homebrew) that you don't want to interfere with, I recommend at least using --prefix="$HOME/local" or some other place on your machine besides /usr/local (default for homebrew) or /opt/local (default for MacPorts).
  • If it worked properly, you should see in the output of configure indicating yes for FileGDB support
  • Build it:
    `make && make install`
    which ogr2ogr        # make sure it's the correct ogr2ogr first
    ogrinfo --formats    # list out the formats
    ogrinfo ~/Downloads/test_fgdb.gdb
    
    #convert FileGDB directly to PostGIS
    ogr2ogr -f "PostgreSQL" PG:"dbname='somedatabase' host='localhost' port='5432'" ~/Downloads/test_fgdb.gdb

Using this build of GDAL in a KyngChaos build of QGIS

# save your current GDAL so you can put it back if you want
cp /Library/Frameworks/GDAL.framework/Versions/1.8/GDAL /Library/Frameworks/GDAL.framework/Versions/1.8/GDAL_orig

# symlink the custom GDAL build to the place QGIS looks
rm /Library/Frameworks/GDAL.framework/Versions/1.8/GDAL
ln -s ~/local/lib/libgdal.dylib /Library/Frameworks/GDAL.framework/Versions/1.8/GDAL

Note: to select one in QGIS, go to Add Vector Layer -> select the Directory radio button -> Select your .gdb directory

I had some problems opening certain FileGDB's. I believe the API only supports FileGDB's created with ArcGIS 10.0+.

More info: http://trac.osgeo.org/gdal/wiki/FileGDB

@jctull
Copy link

jctull commented Nov 3, 2012

The formula was mangled from unexpected markdown. Here it is:
http://pastebin.com/uK6LQpUH

@sc0ttdav3y
Copy link

I found a world of pain getting FileGDB to work using ESRI drivers, but the good news is that as of GDAL 1.11 an open driver has been included. So now you can use homebrew to install it.

It currently requires a bit of tweaking, but here's my instructions - takes 5 mins.
http://scottdavey.net/article/Installing-GDAL-1.11-on-OSX-using-Homebrew-227

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment