J@ArangoDB

{ "subject" : "ArangoDB", "tags": [ "multi-model", "nosql", "database" ] }

Compiling a Debug Version of ArangoDB

Compiling a debug version of ArangoDB is a must for everyone that wants to modify the C++ ArangoDB source code and test their changes locally.

How to do this is different in the 2.8 and 3.0 branches of ArangoDB, but luckily it’s really easy to achieve in both branches.

ArangoDB 2.8

For the 2.8 branch of ArangoDB, clone the 2.8 version of the ArangoDB repository first:

cloning the 2.8 repository
1
2
git clone -b 2.8 https://github.com/arangodb/arangodb
cd ArangoDB

And in that directory execute the following commands:

compiling a debug version of 2.8
1
2
3
4
5
make setup
export CFLAGS="-g -Og"
export CXXFLAGS="-g -Og"
./configure --enable-relative --enable-maintainer-mode
make -j4

(note that you’ll need a working C++11 compiler and some prerequisites such as the OpenSSL library, GNU Bison and Flex installed for this to work).

This will compile ArangoDB and all of its dependencies, and finally make them available in the bin subdirectory of the current directory. There is no need to install ArangoDB using make install. arangod and the client tools can be run locally using the following commands:

running arangod and arangosh
1
2
bin/arangod --console mydb # start arangod in console mode
bin/arangosh # starts an ArangoShell

Now, after any modification to the ArangoDB C++ source code you can re-compile using make. This will only rebuild the things that need to be rebuilt. If the build is successful, the changes you have made should be visible when restarting the binaries.

As the -g option used above will have configured a build with debug symbols, it’s also possible to use a debugger such as gdb for stepping through the executables, attach to the while they are running, or to obtain stack traces in case any of the executables crashed.

ArangoDB 3.0

For the 3.0 branch of ArangoDB, it’s required to once clone that version of the ArangoDB repository into a local directory:

cloning the 3.0 repository
1
2
git clone -b 3.0 https://github.com/arangodb/arangodb
cd ArangoDB

In that directory execute the following commands to configure the build for debugging:

configuring a debug version of 3.0
1
(mkdir -p build; cd build && cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_MAINTAINER_MODE=On ..)

(again you’ll need a working C++11 compiler and some prerequisites such as the OpenSSL library installed for this to work).

This will configure the build to be a debug build, with debug symbols but most optimizations disabled. To build ArangoDB, just execute:

compiling a debug version of 3.0
1
(cd build && make -j4)

To execute one of the binaries, run them from the checkout directory as follows:

running arangod and arangosh
1
2
build/bin/arangod --console mydb # start arangod in console mode
build/bin/arangosh # starts an ArangoShell

After any modification to the ArangoDB C++ source code, build again using (cd build && make -j4) to see the changes in effect. The build is a debug build, meaning you can use a debugger and get meaningful stack traces for core dumps produced by the binaries.

If you got, then I strongly recommend to also enable the Address Sanitizer (ASAN) for your debug build. This can greatly help finding common memory usage errors during development. There is another
blog post about using ASAN in ArangoDB development.