Skip to content
Emil Tin edited this page Nov 28, 2013 · 45 revisions

###Fetch the source

Fetch the source code form GitHub repository

git clone https://github.com/DennisOSRM/Project-OSRM.git

Compilation of the master branch source is done through cmake. The following commands will build OSRM:

mkdir -p build; cd build; cmake ..; make

This will setup cmake, and run the actual compilation. If you later want to recompile, you can just run 'make' from the build folder.

If you have multiple cores available to build you can also pass '-j x' to the make command where x is the number of cores to use.

On Ubuntu or Mac with dependencies installed, there is no need to set any parameters.

It accepts several optional parameters.

  • -DCMAKE_BUILD_TYPE=Debug to compile in debug mode. Only needed for development.
  • -DWITH_TOOLS=1 to compile any further tools. Usually not needed.

Red Hat Enterprise Linux, Fedora, or CentOS

--> See this issue about CentOS/RHEL 6 compiler versions.

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 protobuf-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 protobuf-devel

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 protobuf-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 as a non root user (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_ROOT= flag (see above).

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

Debian Squeeze

Debian Squeeze ships with boost 1.42 but 1.44+ is required by OSRM.

I just managed to build OSRM successfully on Debian Squeeze compiling boost-1.53 myself first.

Use g++-4.3 (g++-4.4 caused some problems with luabindings as reported here https://svn.boost.org/trac/boost/ticket/6631)

Your need to specify your boost location for cmake, e.g.:

   -DBOOST_ROOT=/home/miguel/boost/boost-1.53/lib/

In order to run the binaries I specify the LD_LIBRARY_PATH. Example:

    LD_LIBRARY_PATH=/home/miguel/boost/boost-1.53/lib/ ./osrm-extract  ~/data/osm/germany.osm 

Debian Wheezy

There have been reports that compilation has worked on debian "Wheezy".

To compile on Debian you will probably need to install the following dependencies. (Tested on Debian Wheezy)

sudo apt-get install git libboost-dev gcc g++ cmake libstxxl-dev \
libxml2-dev libbz2-dev zlib1g-dev libzip-dev libboost-filesystem-dev \
libboost-thread-dev libboost-system-dev libboost-regex-dev libgomp1 libpng-dev \
libprotoc7 libprotobuf-dev protobuf-compiler liblua5.1-0-dev libluabind-dev pkg-config libosmpbf-dev

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 libpng-dev libprotoc7 libprotobuf-dev protobuf-compiler liblua5.1-0-dev \
libluabind-dev pkg-config libosmpbf-dev libgdal-dev libboost-program-options-dev

Ubuntu 11.10

sudo apt-get install build-essential git cmake libprotoc-dev libprotobuf7 \
protobuf-compiler libprotobuf-dev libpng-dev libbz2-dev libstxxl-dev libstxxl-doc \
libstxxl1 libxml2-dev libzip-dev libboost-thread-dev libboost-system-dev \
libboost-regex-dev libboost-filesystem-dev libluabind-dev

You also need libosmpbf-dev package, but this package is not available on ubuntu 11.10. It exist only on 12.04 and higher. You can install in manually by downloading the .deb file from http://pkgs.org/download/libosmpbf-dev, and install it by running sudo dpkg -i libosmpbf-dev*.deb

Ubuntu 12.04+

On Ubuntu 12.04 LTS you may run into this issue: https://github.com/DennisOSRM/Project-OSRM/issues/465

sudo apt-get install build-essential git cmake pkg-config libprotoc-dev libprotobuf7 \
protobuf-compiler libprotobuf-dev libosmpbf-dev libpng12-dev \
libbz2-dev libstxxl-dev libstxxl-doc libstxxl1 libxml2-dev \
libzip-dev libboost-all-dev lua5.1 liblua5.1-0-dev libluabind-dev libluajit-5.1-dev

To be able to run cucumber tests, run these as well:

sudo apt-get install rubygems osmosis
sudo gem install bundler
bundle install  #must be run from the OSRM root folder

Mac OS X 10.7.1, 10.8.2

To compile the source on a Mac, please install the homebrew package system. It will provide all necessary dependencies:

brew install boost git cmake protobuf libzip libstxxl libxml2 osm-pbf lua luajit luabind

To be able to run cucumber tests:

brew install osmosis
gem install bundler
bundle install     #must be run from the OSRM root folder