Skip to content
bonham edited this page Nov 18, 2012 · 45 revisions

###Fetch the source

Fetch the source code form GitHub repository

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

Compilation of the 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

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 sparsehash-devel 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 sparsehash-devel gcc-c++ libxml2-devel stxxl-devel boost-devel boost-regex bzip2-devel libzip-devel protobuf-devel sparsehash-devel stxxl-devel ImageMagick-c++-devel libpng libpng-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 subversion

stxxl-devel and sparsehash-devel are not available in the repositories for these distributions a the time of writing, and must be obtained separately. A sparsehash package can be installed from rpm.pbone.net, ie for 64-bit systems download and install sparsehash-devel-1.10-2.fc15.x86_64.rpm. stxxl will 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

There have been reports that compilation has worked on debian "Wheezy". (Debian "Squeeze" seems to be too outdated now).

To compile on Debian you will probably need to install the following dependencies. (This is not verified, Maybe someone can try this and update this section).

sudo apt-get install git libboost-dev gcc g++ scons libstxxl-dev \
libxml2-dev libsparsehash-dev  libbz2-dev zlib1g-dev libzip-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

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

sudo apt-get install build-essential git scons pkg-config libprotoc-dev libprotobuf7 \
protobuf-compiler libprotobuf-dev libosmpbf-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 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

In addition, you need to install luabind. A brew formula is currently awaiting acceptance. Once it's in the main brew repo, you will be able to install it with:

brew install luabind

Until then, it's possible to manually downloading the brew formula from GitHub.

To be able to run cucumber tests:

brew install osmosis
gem install bundler
bundle install