Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kyroskoh/8239ebdb173e34d99217ebc66442b655 to your computer and use it in GitHub Desktop.
Save kyroskoh/8239ebdb173e34d99217ebc66442b655 to your computer and use it in GitHub Desktop.
Building on Ubuntu 14.04 & 16.04 For OSRM (On-Premise)

Prerequisite

Ubuntu 16.04 is recommended.

Please ensure that your username is ubuntu. Example: /home/ubuntu

If not:

sudo adduser ubuntu

Set password for ubuntu:

sudo passwd ubuntu

Assign ubuntu as superuser.

To give the user "ubuntu" unlimited passwordless access to root privileges via the sudo command, edit /etc/sudoers and add the line:

ubuntu   ALL = NOPASSWD: ALL

Building

Ubuntu 16.04 (Recommended)

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 libluabind-dev libtbb-dev libgdal-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 libluabind-dev libtbb-dev libgdal-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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment