If all you are looking for are pre-compiled binaries for macOS, you can get them either:
- Using Homebrew via
brew install gdal
Both include any dependencies necessary (PROJ/GEOS/etc).
But if you need to build GDAL, you have a couple of options.
- Homebrew can do it all for you:
brew install gdal --HEAD
- Follow the BuildingOnUnix instructions.
- Make sure you have Homebrew installed, which will setup XCode & the build tools for you as well.
- To easily get all the available dependencies, use Homebrew:
brew install gdal —-only-dependencies
- Clone the GDAL source code from Github
- Configure & Make following BuildingOnUnix
- If you want to make sure you're using Homebrew's Python, use
If you want to Compile and Debug using XCode, use brew to install gdal, then follow the instructions to setup XCode from here: http://blog.burhum.com/post/35555678746/debugging-makefile-based-projects-using-xcode-gdal-as
!Beware! This information is old and quite possibly broken.
The Framework way
It is possible to compile GDAL in Mac OS, following the instructions from http://www.kyngchaos.com/macosx/build/gdal, but some important things must be taken into account. These are the steps I've followed:
My machine: MacBook with Mac OS X 10.6.8 (Snow Leopard). Update: Also working in Mac OS X 10.9 (Mavericks) and 10.10 (Yosemite)
1.- Install UNIX Tools for Mac, needed to compile. You can find them with XCode, as an option during installation
2.- Install GDAL pre-requisites. All of them can be found as dmg images in KyngChaos wiki except one: Expat. You must compile it. So:
2.1 - Install dmg images (these are the versions for Snow Leopard, but use the ones you need from http://www.kyngchaos.com/software/frameworks):
- UnixImageIO Framework: http://www.kyngchaos.com/files/software/frameworks/UnixImageIO_Framework-1.3.2.dmg
- PROJ Framework: http://www.kyngchaos.com/files/software/frameworks/PROJ_Framework-4.7.0-2-snow.dmg
- GEOS Framework: http://www.kyngchaos.com/files/software/frameworks/GEOS_Framework-3.3.2-1.dmg
2.2 - Compile Expat, following these instructions: http://www.kyngchaos.com/macosx/build/expat
3.- All the Frameworks are installed in /Library/Frameworks. Now, you're ready to compile GDAL. The instructions are here: http://www.kyngchaos.com/macosx/build/gdal. BUT...
The paths shown in the instructions page may not work for you. If you followed the previous steps, the configure line you need to use is:
./configure --with-threads --disable-static --without-grass --with-jasper=/Library/Frameworks/UnixImageIO.framework/unix \ --with-libtiff=/Library/Frameworks/UnixImageIO.framework/unix --with-jpeg=/Library/Frameworks/UnixImageIO.framework/unix \ --with-gif=/Library/Frameworks/UnixImageIO.framework/unix --with-png=/Library/Frameworks/UnixImageIO.framework/unix \ --with-geotiff=/Library/Frameworks/UnixImageIO.framework/unix --with-sqlite3=/Library/Frameworks/SQLite3.framework/unix --with-odbc \ --with-pcraster=internal --with-geos=/Library/Frameworks/GEOS.framework/unix/bin/geos-config --with-static-proj4=/Library/Frameworks/PROJ.framework/unix\ --with-expat=/usr/local --with-curl --with-python --with-macosx-framework --with-pg=/Library/PostgreSQL/9.1/bin/pg_config \ CFLAGS="-Os -arch i386 -arch x86_64" CXXFLAGS="-Os -arch i386 -arch x86_64" LDFLAGS="-arch i386 -arch x86_64"
Add --enable-debug, if you plan to debug GDAL.
WARNING: If you use a GDAL build newer than r23745, you may need to change GDALMake.opt.in. Specifically, replace this line
LIBTOOL_LINK = $(LIBTOOL) --mode=link --tag=LD
LIBTOOL_LINK = $(LIBTOOL) --mode=link
Otherwise, you could get a linker error caused by libtool linking with gcc instead of g++. Related ticket #4557
4.- Execute make & sudo make install.
After that, your GDAL library should be correctly installed in /Library/Frameworks/GDAL.framework. Now you can add /Library/Frameworks/GDAL.framework/unix/bin to your PATH enviroment variable, in order to execute GDAL apps.