DGtal 1.4.0
No Matches
Building DGtal
Author(s) of this documentation:
David Coeurjolly - Martial Tola

This part of the manual describes how to build DGtal on Linux, Mac OS X and Windows.

Introduction and first build

The DGtal library uses cmake to manage the project build on various systems.

To build DGtal in is minimal configuration, you need at least these dependencies:

  • c++ compiler (g++, clang++, ...) with C++17 features
  • [cmake](http://cmake.org) (>3.1, optionally cmake-gui),
  • |boost](http://www.boost.org) boost >= 1.50.0 (no need to have the libraries installed)
  • zlib (already available in most OS)

To build DGtal in is full configuration, you may need these dependencies too:

If you want to generate the documentation, you would need:

  • doxygen >= 1.8.0,
  • graphviz.
Since 1.4, some dependencies could be installed using conan.io. Just install the conan 2 binary and cmake will install all libraries (which may take some time for the first build). For instance:
conan profile detect --force ##Conan profile
cd build
conan install .. --build=missing
cmake .. -G "Visual Studio 15 2017" -DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" -DCMAKE_POLICY_DEFAULT_CMP0091=NEW

Build on Linux-based distributions

To build DGtal from the source archive, we use the CMake tool to generate a Makefile or a project file for various IDE (KDevelop, Xcode, Codeblock...). In most linux distributions, all mandatory and optional dependencies are available as packages (debian, ubuntu, ...). Please refer to your package manager to find the appropriate package name and versions.

An important feature of cmake is the "out-of-source" build process. Let us suppose that DGtal sources are in the DGTALSOURCES folder. Hence, in a terminal you can create a build folder:

mkdir build
cd build

Next, use the cmake command to generate your Unix Makefile project (default generator on Unix/Linux) like below for the minimal DGtal configuration:

cmake ..

For the full DGtal configuration, you have to set these options with cmake:

cmake .. -DWITH_GMP=true -DWITH_ITK=true -DWITH_CAIRO=true -DWITH_QGLVIEWER=true

If no error occurs, you can build the DGtal lib and install it:

sudo make install

Build on Mac OS X

Then, since recent Mac OS systems are unix-like operating systems, the easiest way to compile DGtal with cmake/make is to follow Linux-based instructions from source code archive.

If you use Homebrew package manager on Mac, DGtal is available in the package repository:

brew tap DGtal-team/DGtal
brew install dgtal
DGtal is the top-level namespace which contains all DGtal functions and types.

and to get build options:

brew options dgtal

Main DGtal cmake options

In DGtal CMakeLists.txt, several options can be specified to custom the library build. First, cmake has predefined build options (CMAKE_BUILD_TYPE) such as:

    • Debug: debug mode (e.g. C++ debug flags, DEBUG variable, ...)
    • Release: release build (e.g. optimized C++ compiler options, NDEBUG variable, ...)
  • CMAKE_INSTALL_PREFIX: a string containing the DGtal install path (e.g. by default on some linux: "/usr/local/").

Beside these options, user can also specify these options:

  • BUILD_EXAMPLES (ON/OFF): to build DGtal examples (default: OFF)
  • BUILD_TESTING (ON/OFF): to build the test suite (default: OFF)
  • VERBOSE (ON/OFF): to define the VERBOSE variable (default: OFF). If set to ON, verbose messages are traced out.
  • DEBUG_VERBOSE (ON/OFF): to define the DEBUG_VERBOSE variable (default: OFF). If set to ON, verbose debug messages are traced out.
  • BUILD_SHARED_LIBS (ON/OFF): to build the lib as a shared library (default: OFF) but must be OFF actually on Windows

Build on Windows / Visual Studio

DGtal core library compiles on Windows using Visual Studio 2015 or newer (note that building DGtal on cygwin or MinGW environments is trivial using linux based build). Since DGtal requires C++11 features since release 0.9.1, compiling the library with older Visual Studio compilers is not supported.

To generate the Visual Studio project, use the cmake (or cmake-gui) tools with recent Visual Studio target. During the project generation, you would have to specify the path to boost headers (or paths needed for any optional dependency such as GMP, CGAL, Cairo...).

Do not forget to set BUILD_SHARED_LIBS cmake to false (static DGtal lib target, default).
When working on DGtal within github, we have set up a Windows container for continuous integration.