Skip to content

Latest commit

 

History

History

osx

Building GDAL bindings on OSX (macOS)

Prerequisites

  1. Install homebrew and macports (for hdf4 hdf5 netcdf drivers).
  2. Install base packages with ./before-install.sh
  3. Install dotnet to build Nuget packages

1. Environment

There two types of builds arm64 (Apple Silicon M1 & M2 chipsets) and x86_64 (Intel chipsets). GH Actions runner is using a x64 3-core instances. This build was built using a self-hosted runner on a 10 CPU M2 Mac (arm64).

2. Check for required libraries

VPKG will install all requirements defined in shared/GdalCore.opt file. Latest versions, no collisions with other dynamic libraries.

3. Compiling

Simply run make in current folder to start GNUmakefile which constists of steps described below. Still, you can execute them sequentially if needed.

# install libraries with VCPKG
make -f vcpkg-makefile BUILD_ARCH=arm64

# install main libraries (proj,gdal)
# > optional use [target]-force to run from scratch, ex. gdal-force
make -f gdal-makefile BUILD_ARCH=arm64

# collect dynamic libraries 
make -f collect-deps-makefile BUILD_ARCH=arm64

# create packages (output to 'nuget' folder)
make -f publish-makefile pack BUILD_ARCH=arm64

# testing packages
# > optional PRERELEASE=1 - testing pre-release versions
# > optional APP_RUN=1 - testing via console app run (quick, to ensure deps were loaded correctly)
make -f test-makefile test BUILD_ARCH=arm64

How to check dependencies:

Run tests from the latest step. If everything loads correctly - you're good.

Or after collecting libraries, run otool to view dependencies . Don't forget to set DYLD_LIBRARY_PATH. See copy-deps target in collect-deps-makefile for details. Assumming the repo path is /root/gdal.netcore.

otool -L "/root/gdal.netcore/build-osx/gdal-build/lib/libgdal.dylib"