- 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
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:
- cmake (optionally cmake-gui),
- c++ compiler (g++, clang++, ...)
- boost >= 1.42.0 and boost-program-options.
To build DGtal in is full configuration, you need these dependencies too:
- gmp,
- cairo,
- qglviewer,
- graphicsmagick,
- insighttoolkit (ITK).
If you want to generate the documentation, you would need:
- doxygen >= 1.8.0,
- graphviz.
Build on Linux-based distributions
From a clean Ubuntu installation, you can download and install all dependencies using:
sudo apt-get install cmake g++ libboost-dev libboost-program-options-dev
sudo apt-get install libgmp-dev libcairo2-dev libqglviewer-qt4-dev
libgraphicsmagick++1-dev libinsighttoolkit3-dev libgdcm2-dev doxygen graphviz
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:
cd DGTALSOURCES
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:
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 -DWITH_MAGICK=true
If no error occurs, you can build the DGtal lib and install it:
Build on Mac OS X
First of all,
- download and install Xcode : https://developer.apple.com/xcode/
- with recent version of Xcode (for example 4.3.x) you need then to install the 'Command Line Tools' for Xcode. You can install them from inside Xcode's Download preferences. Finally, you also need to do that command:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
To install DGtal dependencies, we can use any of the available package managers (MacPorts, Fink, Homebrew). However, for DGtal, we recommend to use Homebrew (simpler, faster, ...):
- download and install Homebrew and then update it:
/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
brew update
From a clean Mac OS X Lion (10.7) installation, you first need to do that to install all the dependencies:
brew install cmake doxygen graphviz boost
brew install gmp cairo libqglviewer graphicsmagick
Finally, for now, ITK is not available via Homebrew so you have to download this package and then do:
tar zxvf InsightToolkit-4.1.0.tar.gz
cd InsightToolkit-4.1.0
mkdir build
cd build
cmake ..
make
sudo make install
here 4.1.0 is an example but you may need to adjust the version number...
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.
Build on Windows / Visual Studio
First of all,
Procedure with Visual Studio Express 2008 and 32 bit libraries
- download and extract Boost headers (only "/boost" folder) from source tarball : http://sourceforge.net/projects/boost/files/boost/
- download and extract Boost 32 bit Pre-Built Binaries (vc32-bin file) : http://boost.teeks99.com/
- rename the "/lib32" folder to "/lib"
- make a folder for Boost dependency with inside these 2 folders : the "/boost" folder (for the headers) and the "/lib" folder (for the libraries)
- download and extract yasm Win32 : http://yasm.tortall.net/Download.html
- copy "\mpir-2.2.1\build.vc9\yasm.rules" to the Visual C++ project defaults directory (mine is "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\VCProjectDefaults\")
- rename file yasm-1.2.0-win32.exe to yasm.exe (here 1.2.0 is an example...)
- move yasm.exe to the Visual C++ binary directory (mine is "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\")
- download and extract MPIR (GMP) source tarball : http://www.mpir.org/#release (important, latest for vs2008-32 is http://www.mpir.org/mpir-2.2.1.tar.bz2), then
- open the MPIR Visual C++ solution "\mpir-2.2.1\build.vc9\mpir.sln" (ignore errors) and build lib_mpir_gc project in Win32 Release mode
- library and header files are then in "\mpir-2.2.1\build.vc9\lib\Win32\Release" folder
- download and extract Qt 32 bit Pre-Built Binaries : http://qt.nokia.com/downloads/windows-cpp-vs2008
- set a new QTDIR environment variable with your Qt folder (example "QTDIR=C:\dev32\libs\Qt-4.8.1")
- add at the end of your PATH environment variable your Qt bin path (example "Path=...;C:\dev32\libs\Qt-4.8.1\bin")
- put a qt.conf file in your Qt bin folder, ie just a text file like this one:
[Paths]
Prefix = $(QTDIR)
- download and extract libQGLViewer source tarball : http://www.libqglviewer.com/src/libQGLViewer-2.3.16.zip (here 2.3.16 is an example...)
- open a Command Prompt window (in 'Start button' - 'All Programs' - 'Accessories'), go inside "libQGLViewer-2.3.16\QGLViewer" folder and then do:
qmake -t vclib QGLViewer.pro -spec win32-msvc2008
- open the QGLViewer.vcproj (in QGLViewer folder) with Visual Studio and compile in Win32 Release mode and then in Win32 Debug mode
- library files are then in "QGLViewer\release" and in "QGLViewer\debug"
Procedure with Visual Studio Express 2010 and 64 bit libraries
- download and extract Boost headers (only "/boost" folder) from source tarball : http://sourceforge.net/projects/boost/files/boost/
- download and extract Boost 64 bit Pre-Built Binaries (vc64-bin file) : http://boost.teeks99.com/
- rename the "/lib64" folder to "/lib"
- make a folder for Boost dependency with inside these 2 folders : the "/boost" folder (for the headers) and the "/lib" folder (for the libraries)
- download and extract MPIR (GMP) source tarball : http://www.mpir.org/#release and then
- open the MPIR Visual C++ solution "\mpir-2.5.0\build.vc10\mpir.sln" and build lib_mpir_gc project in x64 Release mode (here 2.5.0 is an example...)
- library and header files are then in "\mpir-2.5.0\build.vc10\x64\Release" folder
- set a new QTDIR environment variable with your Qt folder (example "QTDIR=C:\dev64\libs\Qt-4.8.1")
- add at the end of your PATH environment variable your Qt bin path (example "Path=...;C:\dev64\libs\Qt-4.8.1\bin")
- put a qt.conf file in your Qt bin folder, ie just a text file like this one:
[Paths]
Prefix = $(QTDIR)
- download and extract libQGLViewer source tarball : http://www.libqglviewer.com/src/libQGLViewer-2.3.16.zip (here 2.3.16 is an example...)
- open a windows sdk V7.1 prompt (in 'Start button' - 'All Programs' - 'Microsoft Windows SDK v7.1'), go inside "libQGLViewer-2.3.16\QGLViewer" folder and then do:
SetEnv /Release /x64
qmake -t vclib QGLViewer.pro -spec win32-msvc2010
- open the QGLViewer.vcxproj (in QGLViewer folder) with Visual Studio and compile in x64 Release mode and then in x64 Debug mode
- library files are then in "QGLViewer\release" and in "QGLViewer\debug"
Cairo dependency
Because on Windows, Cairo dependencies are MSYS, curl, zlib, libpng, pixman and a bit long & not so easy to compile, we provide for you the Cairo library and headers files for vs2008-32 and for vs2010-64.
Then, finally, use the cmake Windows interface (cmake-gui) to generate your Visual Studio project. Again, a good practise is to specify a different build folder.
On windows, there are no specific locations in the folder tree where cmake could find the include files and DLLs shared libraries of the DGtal dependencies. Hence, you will have to manually set the paths to find the dependencies.
For example, with cmake-gui,
- the boost dependency must be set with a new BOOST_ROOT path option (with "+ Add Entry" button)
- the gmp-mpir dependency must be set with GMPXX_LIBRARIES (mpir.lib and not mpirxx.lib, important!) and GMP_LIBRARIES (mpir.lib too) file options and GMP_INCLUDE_DIR path option
- the cairo dependency must be set with CAIRO_LIBRAIRIES (cairo.lib and not cairo-static.lib, important!) file option and CAIRO_INCLUDE_DIRS path option
- the qglviewer dependency must be set with QGLVIEWER_LIBRARY_DEBUG (QGLViewerd2.lib) and QGLVIEWER_LIBRARY_RELEASE (QGLViewer2.lib) file options and QGLVIEWER_INCLUDE_DIR path option
Important:
- BUILD_SHARED_LIBS (ON/OFF) must be OFF actually on Windows!
Once the Visual Studio project as been created, you just have to simply open it with VS and compile it (but for the moment there are still compilation errors on Windows with some modules...).
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:
- CMAKE_BUILD_TYPE
- 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: ON)
- BUILD_TESTING (ON/OFF): to build the test suite (default: ON)
- DEBUG_VERBOSE (ON/OFF): to define the DEBUG_VERBOSE variable (default: OFF). If set to ON and in Debug build type, verbose debug messages are traced out.
- BUILD_SHARED_LIBS (ON/OFF): to build the lib as a shared library (default: ON) but must be OFF actually on Windows!