Open
Graph Drawing
Framework

 v. 2020.02 (Catalpa)
 

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.9.2+
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_MODE` is either set to `REGULAR` (it is by default) or `HEAVY` (even more assertions).
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.
181 
182 ## System-wide Installation
183 
184 System-wide installation of OGDF is supported through the standard mechanisms
185 provided by CMake. This support, however, is not thoroughly tested and may
186 change in the future.
187 
188 Current limitations are that Debug and Release installations are not supported
189 at the same time. We also do not provide version information at the moment.
190 
191 ## Building User Code
192 
193 When you want to build user code that uses OGDF, you have to take care of the correct
194 include paths.
195 You should use `<OGDF build directory>/include` and `<OGDF source directory>/include`
196 as include paths, and your OGDF build directory as library path. In case of an in-source
197 build, the build and source directories coincide.
198 It is not supported to have in-source and out-of-source builds at the same time. In case
199 you want to remove an in-source build entirely, do not forget to remove the file
200 `include/ogdf/basic/internal/config_autogen.h`.
201 
202 If you are running into linking errors, undefined behavior or crashes at runtime,
203 a typical mistake is that OGDF and user code is compiled in different modes (like
204 Debug mode and Release mode).
205 To make sure that your configuration is correct, you might use the file
206 `examples/special/check-build-mode.cpp` and try to compile it using your configuration.
207 
208 On Unix systems, typical compilation and linkage of user code would look like this:
209 
210 ```sh
211 # compile source files
212 c++ -Ibuild_path/include -Isource_path/include -o file1.o -c file1.cpp
213 c++ -Ibuild_path/include -Isource_path/include -o file2.o -c file2.cpp
214 # link source files
215 c++ -o output_binary -Lbuild_path file1.o file2.o -lOGDF -lCOIN
216 ```
217 
218 ### Example CMake configuration
219 
220 Since OGDF uses CMake, it is convenient for you to use CMake, too.
221 The file `examples/special/CMakeLists.txt` contains a basic configuration
222 to start with.