Menu

Compiling SAGA on Linux Log in to Edit

Anonymous Volker Wichmann Johan Van de Wauw Markus Kilian Justus Spitzmüller

Compiling SAGA on Linux


Prerequisites (resolving the dependencies)

Use your package manager to install the following packages and development packages:

  • wxWidgets (wxGTK): GTK port of the wxWidgets GUI Library; for newer SAGA versions and git master wxGTK-3.1 is the required minimum version; SAGA versions <= 7.2.0 can be compiled with wxGTK-3.0; the last SAGA version building with wxGTK-2.8.10 was SAGA 2.0.8
  • PROJ: Library for performing conversions between cartographic projections
  • GDAL: Geospatial Data Abstraction Library, required for import and export of various vector and raster formats
  • TIFF: Library functions for manipulating TIFF format image files
  • unixODBC: A complete ODBC driver manager for linux

Optional:

  • OpenMP: required for parallelization of SAGA's core and tools
  • qhull: general dimension convex hull programs, required to disable triangle library
  • libharu: C library for generating PDF files, required for PDF creation
  • opencv: OpenCV core libraries, required for opencv based tools
  • vigra: generic Programming for Computer Vision, required for vigra based tools; additionally requires FFTW, a library for discrete Fourier transform and optionally HDF5 for HDF5 support
  • libsvm: a Library for Support Vector Machines, required for libsvm based tools
  • PDAL: Point Data Abstraction Library, required for LAS/LAZ import/export tools
  • postgresql/postgis: the shared libraries required for any PostgreSQL clients and Geographic Information Systems Extensions to PostgreSQL, required for PostgreSQL/PostGIS support
  • libcurl (https support in webservices)
  • Geotrans (Geographic Translator): required for the pj_geotrans tool library
  • Python: an interpreted, interactive, object-oriented programming language, required to compile SAGA API Python interface
  • swig: Connects C/C++/Objective C to some high-level programming languages, required to compile SAGA API Python interface
  • [deprecated] liblas (<= 1.2): LAS 1.0/1.1/1.2 ASPRS LiDAR data translation toolset, for [deprecated] LAS import/export tools

Note: in order to compile optional SAGA tool libraries, which depend on these additional libraries, you have to install the libraries and their development packages on your build system with the system's package manager before configuring and building SAGA.

Most of the optional tool libraries will be build automatically once their dependencies are detected while configuring the build (see below), including

  • OpenMP, OpenCV, ViGRA (FFTW, HDF5), PDF support, PostgreSQL/PostGIS, PDAL, https support, SAGA API Python interface, [deprecated]libLAS

Others can be enabled by passing their flags to the cmake configure call, e.g.

  • qhull (instead of triangle)
  • SVM (use library installed on your system instead of SAGA's own copy)
  • MRMR (minimum-Redundancy-Maximum-Relevance feature/variable/attribute selection, used by the "Random Forest Classification (ViGrA)" and "Minimum Redundancy Feature Selection" tools)

You can use the following commands to install all required dependencies:

Fedora

dnf install wxGTK-devel proj-devel gdal-devel libtiff-devel unixODBC-devel

openSUSE

For some dependencies (e,g.gdal) the Application:/Geo repository has to be enabled.

zypper ar http://download.opensuse.org/repositories/Application:/Geo/openSUSE_12.1/ GEO

Now the packages can be installed.

zypper install wxWidgets-devel libproj-devel libgdal-devel libtiff-devel

Debian / Ubuntu

apt-get install ibwxgtk3.0-gtk3-dev libtiff5-dev libgdal-dev libproj-dev \
    libexpat1-dev wx-common libogdi-dev unixodbc-dev

For Ubuntu versions <22.10 (Kinetic Kudu) or Debian 11 stable (bullseye) are no wxWidgets/wxGTK greater 3.0.5 (necessary for SAGA > 7.2.0) available. Please consider using a third party PPA like CodeLite.
Install the necessary dependencies from the official repository:

apt-get install libtiff5-dev libgdal-dev libproj-dev libexpat1-dev libogdi-dev unixodbc-dev

Install wxWidgets from the PPA. Please change jammy according to your Ubuntu Release following this page:

apt-add-repository 'deb https://repos.codelite.org/wx3.2/ubuntu/ jammy universe'
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6856E1DB1AC82609
apt update
apt install libwxbase3.2-0-unofficial libwxbase3.2unofficial-dev libwxgtk3.2-0-unofficial libwxgtk3.2unofficial-dev wx3.2-headers wx-common

Arch
Installing packages to be able to build .

pacman -S base-devel cmake

Installing the necessary packages.

pacman -S wxwidgets-gtk3 libtiff gdal pdal proj opencv unixodbv

Installing the optional packages

pacman -S swig libharu liblas libsvm vigra 

AUR Packages : lua-hpdf.


Compilation and configuration tools needed

SAGA uses cmake for configuration and building. The automake build system was removed after the release of SAGA version 8.2 (scroll down for instructions on how to use the automake build system to build older SAGA versions).

Use your package manager to install the following tools:

  • git, a distributed version control system
  • cmake, a cross-platform family of tools designed to build, test and package software; minimum required version is 3.13.3 (if you are building on an older Debian/Ubuntu version, have a look here)
  • a C++ compiler, usually gcc (the GNU compiler collection) or clang (C language family frontend for LLVM)
  • Libtool, a generic library support script

You can use the following commands to install all needed tools:

Fedora

dnf install gcc gcc-c++ cmake cmake-gui make libtool git

openSUSE

zypper install gcc-c++ cmake cmake-gui make git

Ubuntu

apt-get install g++ cmake cmake-qt-gui make libtool git

Downloading SAGA sources

Create the directory you like to download the sources to and change to that directory, e.g.

mkdir /home/devel
cd /home/devel

Check out the git repository with:

git clone git://git.code.sf.net/p/saga-gis/code saga-gis-code

Compiling SAGA

Change to the source directory, e.g.

cd /home/devel/saga-gis-code

Create a build directory, e.g.

mkdir build

Change to the build directory, e.g.

cd build

Configure the build (note: unexperienced users might be better off using cmake-gui for the configuration, see below), e.g.

cmake ../saga-gis -DCMAKE_BUILD_TYPE=RELEASE -DWITH_TRIANGLE=OFF -DWITH_SYSTEM_SVM=ON -DWITH_DEV_TOOLS=OFF

Note: depending on your system setup, the first configuration run may not have found all required dependencies; in this case you should follow the hints that were printed by the first run, e.g. to simply re-run the cmake call. In some cases it might be necessary to explicitly pass arguments to the cmake call for some of the components to be configured. Such a call might look like this for example:

cmake ../saga-gis -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_INSTALL_RPATH=/usr/local/lib -DPYTHON_INCLUDE_DIR=/usr/include/python3.6m -DPYTHON_LIBRARY=/usr/lib64/libpython3.6m.so -DPYTHON_EXECUTABLE=/usr/bin/python3.6 -DWITH_TRIANGLE=OFF -DWITH_SYSTEM_SVM=ON -DWITH_TOOLS_VIGRA=OFF -DWITH_DEV_TOOLS=ON -DSVM_INCLUDE=/usr/include/libsvm/svm.h

You can print all available configuration options with

cmake -LA

or more verbose with

cmake -LAH

You can also use cmake-gui to configure the build, this is sometimes easier for unexperienced users. Run

cmake-gui

Then

  • "Browse Source", e.g. /home/devel/saga-gis-code/saga-gis
  • "Browse Build", e.g. /home/devel/saga-gis-code/build
  • "Configure"
  • if all went well, press the "Generate" button
  • otherwise resolve/edit the values marked in red, configure again, and finally generate the makefiles

Now compile SAGA with

cmake --build . --config Release

To install SAGA, get superuser/root privileges (with sudo su or appropriate command) and run

cmake --install .

Note: on some systems it might be necessary to run "sudo ldconfig" before saga_gui or saga_cmd can be executed.


Running SAGA

To start the graphical user interface of SAGA, just enter

saga_gui &

If the SAGA tool libraries are not loaded automatically, you can load them with the "Geoprocessing > Load Tool Library" menu entry.

To run the SAGA command line interpreter enter

saga_cmd

In case you like to use tool libraries that are not located within the SAGA installation folder, you can specify the environment variable "SAGA_TLB" and let it point to the folder of these tool libraries:

export SAGA_TLB=/usr/local/lib/my_tools

Compilation with the [deprecated] automake build system

Note: the automake build system is only available in SAGA versions < 8.3.0.

Compilation and configuration tools needed

  • Automake, a tool for automatically creating Makefiles
  • Autoconf, a tool for generating configure scripts
  • Libtool, a generic library support script

Compiling SAGA

Change to the source directory, e.g.

cd /home/devel/saga-gis-code/saga-gis

Try a

autoreconf -fi

In case this is not working with your Linux distribution, take the long way:

aclocal
autoheader
libtoolize
automake --add-missing
autoconf

Now compilation should be straightforward with

./configure
make

In case you like to build also the SAGA API python interface, run

./configure --enable-python

before doing make. Note that you require to install the SWIG compiler to build the python interface!

Note: there are further configure options which can be listed with

 ./configure --help

To install SAGA, get superuser/root privileges (with sudo su or appropriate command) and run

 make install

Related

Wiki: Compiling SAGA on Linux (outdated)

Discussion

  • Julie Pierson

    Julie Pierson - 2018-03-15

    Thanks for this useful page. I had to run "sudo ldconfig" after compiling to be able to run SAGA.

     
    • Volker Wichmann

      Volker Wichmann - 2018-03-16

      Thanks, I've added a note.

       

      Last edit: Volker Wichmann 2018-03-16
  • Volker Wichmann

    Volker Wichmann - 2020-04-15

    Hi Markus,

    I saw your latest changes:

    Note: For python3 run [user@localhost ~]$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
    

    It is really welcome that this page gets updates, but I'm not sure if we should really add this. First of all there are already distributions out there that come with python 3. And next, it is quite dangerous for unexperienced users to install an alternative python package on their system. I have done this on my system in order to test a build with python 3, but I have to revert it after that because otherwise my package manager etc. stops working (as it is expecting python 2).

    So if we really want add such a note, I think we should formulate it differently. What do you think?

     
    • Volker Wichmann

      Volker Wichmann - 2020-05-22

      Hi Markus,
      since I didn't hear from you, I've reverted the change as the note is still available here in the discussion.

       
  • Nihal  M

    Nihal M - 2024-07-01

    On a fresh install of ubuntu 24.04 - I get this error -

    -- Could NOT find PDAL (missing: PDAL_DIR)
    CMake Error at cmake/modules/FindPDAL.cmake:112 (MESSAGE):
    Could not find PDAL
    Call Stack (most recent call first):
    src/tools/io/io_pdal/CMakeLists.txt:20 (find_package)

    -- Configuring incomplete, errors occurred!

    https://packages.ubuntu.com/search?keywords=pdal seems to indicate that pdal is missing?

    or did i get something else wrong?

     
    • Volker Wichmann

      Volker Wichmann - 2024-07-01

      Please don't use the wiki to ask questions, such topics are better discussed in the forums.

      Seems like there is no PDAL package available for Ubuntu 24.04 yet, so you should disable the build of the io_pdal tool library. Configure cmake with
      -DWITH_TOOLS_PDAL=OFF

       
      👍
      1

Log in to post a comment.