J@ArangoDB

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

Using Travis CI for a C++11 Project

TravisCI is a very useful cloud service for continous integration. It can be integrated with Github, with each commit triggering a new build and reporting back when it broke something.

Travis has support for many programming languages, among them C++. But it lacks support for C++11 features.

Travis provides basic support for C++ projects. It comes with gcc, clang, the autotools, make, cmake and scons.

While writing this post, Travis CI build machines run on Ubuntu 12.04 LTS 64 bit. This version of Ubuntu is rather old already, and does not bring too many packages for C++11 development. For example, the default C++ compiler installed on TravisCI is g++-4.6.3. This version doesn’t even understand the compile option -std=c++11.

Official C++11 support started in g++ 4.7, though C++0x features were supported way earlier. But to get decent C++11 support in g++, it is best to use g++4.8 or higher.

Fortunately TravisCI allows installing other software. To get a more recent C++ compiler, it can simply be added from a PPA. This can be achieved by putting the PPA in the .travis.yml file of your Github repository, e.g.

1
2
3
4
5
6
7
8
9
10
language: cpp
compiler: g++

before_install:
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get update -qq

install:
- sudo apt-get install -qq g++-4.8
- export CXX="g++-4.8"

I have set up an example project on Github that demonstrates how to use it.