Skip to content
DennisOSRM edited this page Apr 23, 2013 · 29 revisions

###Fetch the source

Fetch the source code form GitHub repository

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

Master branch

Compilation of the master branch source is usually done through scons. The source comes with a SConstruct that takes care of dependency checking. The SConstruct accepts several optional parameters.

  • --stxxl=/path/to/root_of_stxxl sets the root directory of stxxl when it resides in a non-default path.
  • --cxx=/path/to/compiler/g++ sets the C++ compiler. GCC and LLVM/Clang work, but Clang has no OpenMP support.
  • --build=debug/release either builds in debug (no optimization) or release mode (full optimizations).
  • --no-march without any values controls whether to use platform specific optimizations or not. May be handy on (misconfigured) virtual machines that do not support the full instruction set of the underlying hardware.
  • -j x where x is the number of parallel threads to use during compilation

To launch compilation process just do

$ scons

If you need to clean your build directory (such as when switching branches etc and want to be sure that all is clean), use $ scons -c.

Develop branch

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

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

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.

Red Hat Enterprise Linux, Fedora, or CentOS

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 scons

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 scons

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 scons using the --stxxl= 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)

I added this two lines to my SConstruct file. You will have to adapt this to your boost location.

    env.Append(CPPPATH = ['/home/miguel/boost/boost-1.53/include/'])
    env.Append(LIBPATH = ['/home/miguel/boost/boost-1.53/lib/'])

I added the lines right before this line:

    env.Append(CPPPATH = ['/usr/include', '/usr/include/include', '/usr/include/libxml2/'])

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++ scons libstxxl-dev \
libxml2-dev libsparsehash-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

Ubuntu 11.10

sudo apt-get install build-essential git scons 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 scons 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-thread-dev libboost-system-dev libboost-regex-dev \
libboost-filesystem-dev lua5.1 liblua5.1-0-dev libluabind-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 scons protobuf libzip libstxxl libxml2 osm-pbf lua luajit luabind

To be able to run cucumber tests:

brew install osmosis
gem install bundler
bundle install

Clone this wiki locally