J@ArangoDB

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

Compiling ArangoDB 3.0 on Ubuntu

We have spent a lot of time working on ArangoDB 3.0. That version will not only provide major functionality and performance improvements, but will also come with an improved, CMake-based build system.

This post explains how to use CMake to build ArangoDB 3.0 on a recent Ubuntu Linux. For the impatient there’s a command summary at the end of this post.

Installing prerequisites

Here’s how to build ArangoDB 3.0 with cmake on a recent Ubuntu Linux.

Ubuntu 15.x and 16.x should have recent enough packages so any missing prerequisites can be installed via a simple sudo apt-get install command:

installing prerequisites
1
sudo apt-get install cmake make build-essential openssl python2.7 g++ gcc

Older versions of Ubuntu can be convinced to work too, but this requires a g++ version of at least 4.9. Ubuntu 14 ships with older g++ versions by default, so you will first need to install a newer g++ version (see here or here for some external instructions). Once the g++ and gcc compilers are recent enough, install the other prerequisites.

Cloning ArangoDB

After having installed the prerequisites, clone the ArangoDB repository from Github and then cd into the directory arangodb that the cloning will have created:

cloning ArangoDB
1
2
git clone https://github.com/arangodb/arangodb
cd arangodb

Then check out the 3.0 branch and pull the latest changes:

cloning ArangoDB
1
2
git checkout 3.0
git pull

Building ArangoDB

A convention when using CMake is to not build directly in the source directory, but use a separate build directory instead. The benefit of this is that building in a separate directory won’t change the source directory, and the build directory can be disposed easily.

To create an initial build directory named build and cd into it, just type:

creating a build directory
1
2
mkdir -p build
cd build

It’s now time to invoke CMake. CMake should be executed from the build directory, but needs to know where it’s build instructions file (named CMakeLists.txt is). This file is located in the source directory. To run CMake without any specific options, we can use:

running CMake
1
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..

This will run CMake from inside the build directory and tell it to look for CMakeLists.txt in the source directory. The -DCMAKE_BUILD_TYPE=RelWithDebInfo part will tell CMake to build binaries with optimizations and debug symbols. Other useful build types are:

  • -DCMAKE_BUILD_TYPE=Debug: without optimizations, for debugging only
  • -DCMAKE_BUILD_TYPE=Release: with optimizations, no debug symbols, not useful for debugging

Invoking CMake will perform some checks for required components, compiler and platform features. If anything fails, it should print some error message. If everything works well, the command should have created a Makefile in the build directory.

side note: CMake on Linux will by default generate UNIX Makefiles, but it can also be told to generate ninja files instead. On Windows it can generate solution files for Visual Studio.

Now that the Makefile is there, we can run make as usual (note that the -j4 means to build with 4 parallel processes – adjust as needed!):

running make
1
make -j4

Starting arangod and arangosh

And that’s already it for a normal build. Note that the build artefacts and thus the binaries will also be created inside the build directory. arangod and arangosh will be located in the bin subdirectory of the build directory. There is no need to install these binaries, they can be run without installing them first. However, starting them from inside the build directory will not work, because they will complain about missing files. It is better to cd one level up first and then start them:

starting arangod
1
2
cd ..
build/bin/arangod ~/testdata --server.authentication false

The former will start arangod with default configuration, with a fresh database directory located in ~/testdata.

If you ran all the commands on your local machine (127.0.0.1) then you can now open a browser and point it to http://127.0.0.1:8529/. This should bring up ArangoDB’s web interface.

You can alternatively start an ArangoShell to connect to the ArangoDB server. In another terminal window, cd into the arangodb directory and start an ArangoShell as follows:

starting arangosh
1
2
cd arangodb
build/bin/arangosh

You should now see the ArangoShell prompt and be able to type some commands!

Command summary

Note: in contrast to the above step-by-step instructions, some commands here have been put together on a single line to make developer’s life easier.

installing prerequisites
1
sudo apt-get install cmake make build-essential openssl python2.7 g++ gcc
initial checkout of the 3.0 branch and build configuration
1
2
3
4
5
6
git clone https://github.com/arangodb/arangodb
cd arangodb
git checkout 3.0
git pull
mkdir -p build
(cd build && cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..)
Update, build and run cycle
1
2
3
git pull
(cd build && make -j4)
build/bin/arangod ~/testdata --server.authentication false