-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Building OSRM
OSRM source is available via git or source archives, and is built with CMake.
To download from Git, run the following commands:
git clone https://github.com/Project-OSRM/osrm-backend.git
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>
.
OSRM can be built from the source archives available on the releases page. Example:
wget https://github.com/Project-OSRM/osrm-backend/archive/vX.Y.Z.tar.gz
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:
-
Building on Ubuntu - using
apt
(the default, try this first) - Building with Mason - using Mason (fetching pre-built packages externally)
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.
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)
git clone https://github.com/Project-OSRM/osrm-backend.git
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
make
Please install the homebrew package system. It will provide all necessary dependencies:
brew install boost git cmake libzip libstxxl libxml2 lua51 luabind tbb ccache
To be able to compile tools:
brew install GDAL
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 https://github.com/Project-OSRM/osrm-backend.git
mkdir –p Project-OSRM/build
cd Project-OSRM/build
cmake ..
make
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.