1 [OGDF](../README.md) ยป Build Guide
5 The OGDF build configuration is generated using [CMake](http://www.cmake.org/).
10 * C++11 compliant compiler
13 * Microsoft Visual C++ 2015+
14 * GNU Make (in most cases)
15 * Doxygen 1.8.6+ (optional)
17 ## Build Configuration
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.
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.
29 All of the examples cover unix systems. On windows, CMake provides a self-explanatory graphical user interface.
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 `~`.
34 CMake will present you with several options for configuring your build.
35 All of these options are explained by the CMake interface.
37 ### Default Configuration
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.
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).
57 -- Other important targets:
58 -- doc: build doxygen documentation (in-source)
60 -- examples: build examples
61 -- build-all: build OGDF, tests, examples
64 -- Build files have been written to: ~/OGDF
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.
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
86 ### Out-of-Source Build
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.
92 $ mkdir my-out-of-source-build
93 $ cd my-out-of-source-build
98 -- Build files have been written to: ~/my-out-of-source-build
101 Note that the documentation is always built in-source.
103 ### Custom Configuration
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.
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.
115 $ mkdir ogdf-release ogdf-debug
117 $ cmake ../OGDF # default configuration
122 BUILD_SHARED_LIBS >OFF
123 CMAKE_BUILD_TYPE Release
124 CMAKE_INSTALL_PREFIX /usr/local
126 OGDF_MEMORY_MANAGER POOL_TS
127 OGDF_SEPARATE_TESTS OFF
128 OGDF_USE_ASSERT_EXCEPTIONS OFF
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)
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
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
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)
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.
165 There are two modes how failed assertions are handled.
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).
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.
182 ## System-wide Installation
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.
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.
191 ## Building User Code
193 When you want to build user code that uses OGDF, you have to take care of the correct
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`.
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.
208 On Unix systems, typical compilation and linkage of user code would look like this:
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
215 c++ -o output_binary -Lbuild_path file1.o file2.o -lOGDF -lCOIN
218 ### Example CMake configuration
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