Building OSRM

Mirko edited this page Oct 8, 2017 · 119 revisions

General build instructions from source

OSRM source is available via git or source archives, and is built with CMake.


To download from Git, run the following commands:

git clone
cd osrm-backend

If you would like to build a specific release (optional), you can list the release tags with git tag -l and then checkout a specific tag using git checkout tags/<tag_name>.

Source Release

OSRM can be built from the source archives available on the releases page. Example:

tar -xzf vX.Y.Z.tar.gz
cd osrm-backend-X.Y.Z


See below for required dependencies.

mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
sudo cmake --build . --target install


For Ubuntu we support two ways of getting dependencies installed:

Debian Jessie

Use the following command to install the dependencies (git is used to fetch the source):

sudo apt-get install git g++ cmake libboost-dev libboost-filesystem-dev libboost-thread-dev \
libboost-system-dev libboost-regex-dev libstxxl-dev libxml2-dev libsparsehash-dev libbz2-dev \
zlib1g-dev libzip-dev libgomp1 liblua5.1-0-dev \
pkg-config libgdal-dev libboost-program-options-dev libboost-iostreams-dev \
libboost-test-dev libtbb-dev libexpat1-dev

Building on Squeeze and Wheezy requires getting a recent gcc, boost, and other packages. Probably building them from source. It can be done but is unsupported and not recommended. Open a ticket if you need help there.

Mac OS X 10.7.1, 10.8.2

To compile the source on a Mac, first make sure the latest XCode is installed. And ensure you are running at least OS X >= 10.10.

On OS X and Ubuntu systems there are two key modes you can build in:

  • ENABLE_MASON=OFF (default): this most requires all dependencies be installed externally (via homebrew, etc)
  • ENABLE_MASON=ON: this mode fetches most required dependencies automatically (no need to install deps like libboost or libstxxl)

OS X with MacPorts

Download and compile stxxl[0] manually

port install build-essential git cmake pkg-config libbz2 libxml2 libzip boost lua tbb



git clone
cd osrm-backend
./third_party/mason/mason install cmake 3.6.2
export PATH=$(./third_party/mason/mason prefix cmake 3.6.2)/bin:$PATH
mkdir build
cd build
cmake ../ -DENABLE_MASON=1


Please install the homebrew package system. It will provide all necessary dependencies:

brew install boost git cmake libzip libstxxl libxml2 lua tbb ccache

To be able to compile tools:

brew install GDAL

Red Hat Enterprise Linux, Fedora, or CentOS

CentOS 7.x

CentOS 7.x only ships with gcc 4.8.5 which is too old to build OSRM, so install a more recent gcc from the CentOS Software Collections:

yum install yum-utils centos-release-scl
yum-config-manager --enable rhel-server-rhscl-7-rpms
yum install devtoolset-6

Start a new shell with the gcc-6 environment:

scl enable devtoolset-6 bash

A few other dependencies are needed:

yum install git cmake zlib-devel

For all other dependencies make use of mason so that Boost and so on don't have to be built manually as well:

git clone
cd osrm-backend
mkdir build
cd build
make install


See this issue about CentOS/RHEL 6 compiler versions.

See this issue about Fedora and Lua 5.3.

See this page to install osrm-backend on Centos 6.

If compiling on Red Hat Enterprise Linux, Fedora, or CentOS then you will need to enable the EPEL repositories in order to satisfy dependencies.

To compile on Fedora 14 you will need to first install at least the following dependencies:

yum install gcc-c++ libxml2-devel stxxl-devel boost-devel bzip2-devel cmake

To compile on Fedora 15 you will need to first install the following dependencies:

yum install gcc-c++ libxml2-devel stxxl-devel boost-devel boost-regex bzip2-devel libzip-devel

To compile on Fedora 20 you will need to first install the following dependencies:

sudo yum install git cmake gcc-c++

sudo yum install libxml2-devel boost-devel boost-regex bzip2-devel \
     libzip-devel stxxl-devel \
     lua.x86_64 lua-devel.x86_64 luajit.x86_64 luajit-devel.x86_64 \
     expat expat-devel tbb tbb-devel

Finally, follow the installation of Project-OSRM:

git clone
mkdir –p Project-OSRM/build
cd Project-OSRM/build
cmake ..
sudo make install

To compile on Cent OS 6 / RHEL 6 you will need to first install the following dependencies:

yum install gcc-c++ libxml2-devel boost-devel bzip2-devel cmake

stxxl-devel is not available in the repositories for these distributions a the time of writing, and must be obtained separately. It needs to be manually downloaded, extracted and installed on your system (clear instructions can be found in the stxxl documentation). You then need to specify the location of your stxxl installation when you use cmake using the -DSTXXL_LIBRARY=/somewhere/libstxxl.a flag (see above).

OSRM cannot be compiled on RHEL 5 / CentOS 5 without manually compiling a recent version of libboost.

CentOS 6.X

  1. Install updated gcc (as root)
yum install yum-utils centos-release-scl
yum-config-manager --enable rhel-server-rhscl-6-rpms
yum install devtoolset-6
  1. Install some dependencies (as root)
yum install git cmake zlib-devel 
  1. Enable gcc 6 (in a shell as user)
scl enable devtoolset-6 bash
  1. Check version
gcc --version
  1. Compile stxxl-devel from source (as user in the shell with gcc 6 enabled)
git clone stxxl
mkdir stxxl/build
cd stxxl/build
cmake -DCMAKE_BUILD_TYPE=Release ..  # Disable debug mode
  1. Compile and install new updated version of glibc (version 2.14). This has to be done in a shell with no gcc 6 enabled (it needs standard gcc of Centos 6.x)
mkdir glibc_2.14
cd glibc_2.14
tar xvzf glibc-2.14.tar.gz
cd glibc-2.14
mkdir build
cd build
../configure --prefix=/opt/glibc-2.14
make -j4
sudo make install
  1. Install OSRM
git clone osrm-backend
mkdir osrm-backend/build
cd osrm-backend/build
cmake .. -DENABLE_MASON=ON -DSTXXL_LIBRARY=<PATH_TO_STXXL>/stxxl/build/lib/libstxxl.a
make install
  1. Before running osrm-* commands export new glibc 2.14 library
export LD_LIBRARY_PATH=/opt/glibc-2.14/lib


Windows Compilation

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.