Skip to content

Build GDAL from source

swoellauer edited this page Jun 29, 2023 · 1 revision

On Ubuntu, following steps build GDAL binaries including Java bindings.

Further details can be found on the official GDAL documentation.

# install builder
sudo apt install cmake

# install compiler
sudo apt install build-essential

# install java
sudo apt install openjdk-11-jdk

# install java builder
sudo apt install ant

# install SWIG bindings generator
sudo apt install swig

# install PROJ
sudo apt install libproj-dev

# download GDAL sources
wget https://github.com/OSGeo/gdal/releases/download/v3.7.0/gdal-3.7.0.tar.gz

# extract GDAL sources
tar -xzvf gdal-3.7.0.tar.gz

# go to GDAL folder
cd gdal-3.7.0

# create build folder
mkdir build

# go to build folder
cd build

# configure build: minimal
cmake -DCMAKE_BUILD_TYPE=Release -DGDAL_BUILD_OPTIONAL_DRIVERS=OFF -DOGR_BUILD_OPTIONAL_DRIVERS=OFF -DBUILD_JAVA_BINDINGS=ON -DBUILD_PYTHON_BINDINGS=OFF -DBUILD_APPS=OFF ..

# build
cmake --build .

# build and copy to system folders
sudo cmake --build . --target install