Switch between two versions of GDAL on a Mac

I’m a big fan of Qgis and use it all the time. It’s gotten so stable and fast. It is such a joy to use now! On one of the recent versions that I upgraded to it went from using GDAL 1.11.x to using 2.1.x. This is great, but sometimes I need to be able to write to File Geodatabases. The FileGDB driver and the ESRI FileGDB API SDK that I installed for GDAL 1.11.x no longer works under GDAL 2.1, and as far as I can tell, there is no ESRI FileGDB API SDK that is compatible with GDAL 2.1.x.

So, GDAL 1.11.x is still installed on my machine with the FileGDB drivers, but how can I switch back and forth between 2.1 and 1.11 so that I can still use GDAL 2.1.x with QGIS, but be able to use GDAL 1.11.x on the occasions that I have to deal with file geodatabases? Luckily, there is a simple symlink that points to the current version and re-pointing the symlink is all we need to do.

So, here we go:

First, add GDAL to your PATH variable so you can use GDAL/OGR commands
in a terminal window. (skip this if you already use GDAL from the command line).

echo 'export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH' >>~/.bash_profile

source ~/.bash_profile

#cd over to the GDAL Framework ‘Versions’ directory

cd /Library/Frameworks/GDAL.framework/Versions/

#list the folder to see the installed versions and the ‘Current’ symlink.

ls -lah

you should see something like this, with the ‘Current’ Symlink pointing at version 2.1:

 #check the current GDAL/OGR version:

gdalinfo --version

 should be 2.1.x, the same as the symlink.

#just for kicks, show that we don’t have access to the ESRI FileGDB driver with 2.1.x:

ogrinfo --formats | grep "FileGDB"

 as expected, we only have the OpenFileGDB driver.

Ok, now let’s make the switch.

#unlink, and then re-point the symlink at the older version of GDAL:

unlink Current && ln -s 1.11 /Library/Frameworks/GDAL.framework/Versions/Current

#and list the folder again to show the modified symlink:

ls -lah

now your active GDAL version has changed to the older version. 1.11 in this case.

#check your GDAL version, it should be the older one now:

gdalinfo --version

#check the available formats, this should show the ESRI FileGDB drivers (if you’ve installed them):

ogrinfo --formats | grep "FileGDB"

Now you can use GDAL as normal. Your newer installation of QGIS might not work properly with this older version of GDAL, so just use it from the command line. Once you’re done messing with your file geodatabases, re-point the symlink back to GDAL 2.1.x:

#re-point the symlink back to GDAL 2.1.x:

unlink Current && ln -s 2.1 /Library/Frameworks/GDAL.framework/Versions/Current

#and check the version, which should be switched back to 2.1.x:

gdalinfo --version