Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

doc/build.md
Go to the documentation of this file.
1 [OGDF](README.md) ยป Build Guide
2 
3 # Build Guide {#build}
4 
5 The OGDF build configuration is generated using [CMake](http://www.cmake.org/).
6 
7 ## Requirements
8 
9  * CMake 3.1+
10  * C++11 compliant compiler
11  * gcc 4.8+
12  * clang 3.5+
13  * Microsoft Visual C++ 2015+
14  * GNU Make (in most cases)
15  * Doxygen 1.8.6+ (optional)
16 
17 ## Build Configuration
18 
19 CMake is a meta-build system that will generate your actual build system.
20 The most common build systems include Unix Makefiles, Visual Studio project files, and XCode project files.
21 We refer to [Running CMake](http://www.cmake.org/runningcmake/) for extensive information on using CMake.
22 
23 Note that CMake allows you to place the generated build system in a separate folder,
24 thus allowing several parallel build configurations (called out-of-source builds).
25 We recommend following this approach.
26 
27 ## Unix Examples
28 
29 All of the examples cover unix systems. On windows, CMake provides a self-explanatory graphical user interface.
30 
31 We assume that the directory `~/OGDF` contains a clone of this repository.
32 In each of the examples we are initially located in the home directory `~`.
33 
34 CMake will present you with several options for configuring your build.
35 All of these options are explained by the CMake interface.
36 
37 ### Default Configuration
38 
39 This will generate the default build system inside the OGDF directory.
40 Such a configuration is sufficient if you want to compile the Library with a single configuration only.
41 
42 ```
43 $ cd OGDF
44 $ cmake .
45 -- The CXX compiler identification is GNU 6.2.0
46 -- Check for working CXX compiler: /usr/bin/c++
47 -- Check for working CXX compiler: /usr/bin/c++ -- works
48 -- Detecting CXX compiler ABI info
49 -- Detecting CXX compiler ABI info - done
50 -- Detecting CXX compile features
51 -- Detecting CXX compile features - done
52 -- Performing Test has_sse3_pmmintrin
53 -- Performing Test has_sse3_pmmintrin - Success
54 -- Found Doxygen: /usr/bin/doxygen (found version "1.8.8")
55 -- The default target builds OGDF (and dependencies like COIN).
56 --
57 -- Other important targets:
58 -- doc: build doxygen documentation (in-source)
59 -- tests: build tests
60 -- examples: build examples
61 -- build-all: build OGDF, tests, examples
62 -- Configuring done
63 -- Generating done
64 -- Build files have been written to: ~/OGDF
65 ```
66 
67 Assuming your system supports Unix Makefiles you could now start the actual build:
68 Note that invoking make with the `-j` flag will execute jobs in parallel thus speeding up your build.
69 
70 ```
71 $ make -j8
72 Scanning dependencies of target COIN
73 Scanning dependencies of target OGDF
74 [ 0%] Building CXX object CMakeFiles/COIN.dir/src/coin/Clp/ClpConstraintLinear.cpp.o
75 [ 0%] Building CXX object CMakeFiles/COIN.dir/src/coin/Clp/ClpCholeskyBase.cpp.o
76 [ 0%] Building CXX object CMakeFiles/COIN.dir/src/coin/Clp/ClpConstraint.cpp.o
77 [ 1%] Building CXX object CMakeFiles/COIN.dir/src/coin/Clp/ClpCholeskyTaucs.cpp.o
78 [ 1%] Building CXX object CMakeFiles/COIN.dir/src/coin/Clp/ClpCholeskyDense.cpp.o
79 [ 1%] Building CXX object CMakeFiles/COIN.dir/src/coin/Clp/ClpConstraintQuadratic.cpp.o
80 [ 1%] Building CXX object CMakeFiles/COIN.dir/src/coin/Clp/ClpDualRowDantzig.cpp.o
81 [ 1%] Building CXX object CMakeFiles/COIN.dir/src/coin/Clp/ClpDualRowPivot.cpp.o
82 [ 2%] Building CXX object CMakeFiles/OGDF.dir/src/ogdf/augmentation/DfsMakeBiconnected.cpp.o
83 ...
84 ```
85 
86 ### Out-of-Source Build
87 
88 An out-of-source build does not modify the source directory.
89 Thus, generating a second out-of-source build will not create any conflicts with the previous one.
90 
91 ```
92 $ mkdir my-out-of-source-build
93 $ cd my-out-of-source-build
94 $ cmake ../OGDF
95 ...
96 -- Configuring done
97 -- Generating done
98 -- Build files have been written to: ~/my-out-of-source-build
99 ```
100 
101 Note that the documentation is always built in-source.
102 
103 ### Custom Configuration
104 
105 Creating multiple build configurations is of no use if the configurations do not differ.
106 Run `ccmake` instead of `cmake` to modify the build configuration before generating the build system.
107 
108 This includes the specification of the linear program solver,
109 whether to include OGDF specific assertions (and how to handle them),
110 additional include directories, and the likes.
111 Running `ccmake` also allows you to specify the compiler, linker and the respective flags.
112 Note that the availability of some options may depend on other configuration values.
113 
114 ```
115 $ mkdir ogdf-release ogdf-debug
116 $ cd ogdf-release
117 $ cmake ../OGDF # default configuration
118 $ cd ../ogdf-debug
119 $ cmake ../OGDF
120 $ ccmake .
121 
122  BUILD_SHARED_LIBS >OFF
123  CMAKE_BUILD_TYPE Release
124  CMAKE_INSTALL_PREFIX /usr/local
125  COIN_SOLVER CLP
126  OGDF_MEMORY_MANAGER POOL_TS
127  OGDF_SEPARATE_TESTS OFF
128  OGDF_USE_ASSERT_EXCEPTIONS OFF
129 
130 BUILD_SHARED_LIBS: Whether to build shared libraries instead of static ones.
131 Press [enter] to edit option
132 Press [c] to configure
133 Press [h] for help Press [q] to quit without generating
134 Press [t] to toggle advanced mode (Currently Off)
135 
136 ....
137 
138  BUILD_SHARED_LIBS OFF
139  CMAKE_BUILD_TYPE Debug
140  CMAKE_INSTALL_PREFIX /usr/local
141  COIN_EXTERNAL_SOLVER_INCLUDE_D /opt/gurobi/linux64/include
142  COIN_EXTERNAL_SOLVER_LIBRARIES /opt/gurobi/linux64/lib/libgurobi70.so
143  COIN_SOLVER GRB
144  OGDF_LEAK_CHECK OFF
145  OGDF_MEMORY_MANAGER >MALLOC_TS
146  OGDF_SEPARATE_TESTS OFF
147  OGDF_USE_ASSERT_EXCEPTIONS ON
148  OGDF_USE_ASSERT_EXCEPTIONS_WIT ON_LIBDW
149 
150 OGDF_MEMORY_MANAGER: Memory manager to be used.
151 Press [enter] to edit option
152 Press [c] to configure Press [g] to generate and exit
153 Press [h] for help Press [q] to quit without generating
154 Press [t] to toggle advanced mode (Currently Off)
155 ```
156 
157 #### On assertions
158 
159 OGDF code has a lot of extra assertions in its code, partly adding running time.
160 These assertions are only activated in debug mode and if the advanced option
161 `OGDF_DEBUG` is activated (it is by default).
162 The assertions (plus a backtrace of the calls) might be very valuable and
163 helpful for debugging (user) code.
164 
165 There are two modes how failed assertions are handled.
166 
167 If `OGDF_USE_ASSERT_EXCEPTIONS` is turned off (default), an `assert()`
168 call exits the program.
169 Note that enabling this might hide failed assertions when `catch (...)` is used.
170 You can get a call stack trace if the program was invoked with a debugger
171 (which is part of many IDEs).
172 
173 If turned on, an `ogdf::AssertionFailed` exception is thrown instead.
174 The informational string returned by the `what()` method contains the
175 failed expression, its source code file, line, and function.
176 By also setting the `OGDF_USE_ASSERT_EXCEPTIONS_WITH_STACK_TRACE` variable to
177 `ON_LIBDW` (if libdw is installed, recommended), `ON_LIBBFD` (if libbfd
178 from binutils is installed), or `ON_LIBUNWIND` (if libunwind is installed),
179 a stack trace will be part of the exception's `what()` return string.
180 As far as we know, this feature only works on Linux.