Skip to content
Richard Fairhurst edited this page Jan 25, 2021 · 27 revisions

This page describes building OSRM on Ubuntu using the system's apt package manager.

See Building with Mason for how to use external pre-built packages instead.

Ubuntu 16.04, 18.04, 20.04

sudo apt install build-essential git cmake pkg-config \
libbz2-dev libstxxl-dev libstxxl1v5 libxml2-dev \
libzip-dev libboost-all-dev lua5.2 liblua5.2-dev libtbb-dev

Ubuntu 15.10

sudo apt-get install build-essential git cmake pkg-config \
libbz2-dev libstxxl-dev libstxxl1v5 libxml2-dev \
libzip-dev libboost-all-dev lua5.2 liblua5.2-dev libtbb-dev

Ubuntu 15.04

sudo apt-get install build-essential git cmake pkg-config \
libbz2-dev libstxxl-dev libstxxl1 libxml2-dev \
libzip-dev libboost-all-dev lua5.2 liblua5.2-0-dev libtbb-dev

Ubuntu 14.04

The most critical packages which should be as recent as possible are: a compiler for C++14 (GCC 4.9+, Clang 3.4+), CMake for the buildsystem (2.8.11+) and Boost 1.55+. GCC can be upgraded using the ubuntu-toolchain-r/test ppa.

You have to update your compiler. GCC 4.8 ships per default but is too old for C++14:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-6 gcc-6 build-essential git wget cmake3 pkg-config libbz2-dev libstxxl-dev libstxxl1 libxml2-dev libzip-dev libboost-all-dev lua5.2 liblua5.2-dev libtbb-dev

and either export the new compiler per session

export CPP=cpp-6 CC=gcc-6 CXX=g++-6

or set it globally

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6 20
sudo update-alternatives --install /usr/bin/cpp cpp /usr/bin/cpp-6 20

You may have to export GCC specific binutils when building with link-time optimization:

export AR=gcc-ar-4.9 NM=gcc-nm-4.9 RANLIB=gcc-ranlib-4.9

or disable link-time optimization:

cmake .. -DCMAKE_BUILD_TYPE=Release -DENABLE_LTO=OFF

Earlier Ubuntu versions

You're pretty much on your own here: you need to update CMake, your compiler and have to compile every C++ dependency locally against your new compiler yourself. It's possible for sure; if you really need to do this and need help open a ticket or ping us on IRC.