-
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
# optionally checkout a particular revision/tag
git checkout v5.27.1
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 libxml2-dev libsparsehash-dev libbz2-dev \
zlib1g-dev libzip-dev libgomp1 liblua5.3-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)
port install build-essential git cmake pkg-config libbz2 libxml2 libzip boost lua tbb
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 libxml2 lua tbb ccache pkg-config
To be able to compile tools:
brew install GDAL
Install scl-utils:
yum install scl-utils
Install GCC Toolset 9:
yum install gcc-toolset-9
Run bash using the following command:
scl enable gcc-toolset-9 bash
Install the following packages:
yum install git cmake3 zlib-devel
Clone osrm-backed:
git clone https://github.com/Project-OSRM/osrm-backend.git
Finally build OSRM:
cd osrm-backend
mkdir build
cd build
cmake3 .. -DENABLE_MASON=ON -DCMAKE_CXX_COMPILER=/opt/rh/gcc-toolset-9/root/usr/bin/g++
make
make install
If you run into problems while extracting/contracting big PBF files
you can go back and add these arguments to your cmake
command and try again:
-DCMAKE_BUILD_TYPE=Release -DENABLE_STXXL=On -DENABLE_LTO=On
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 cmake3 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 https://github.com/Project-OSRM/osrm-backend.git
cd osrm-backend
mkdir build
cd build
cmake3 .. -DENABLE_MASON=ON -DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-6/root/usr/bin/g++
make
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 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 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 \
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
OSRM cannot be compiled on RHEL 5 / CentOS 5 without manually compiling a recent version of libboost.
- 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
- Install some dependencies (as root)
yum install git cmake zlib-devel
- Enable gcc 6 (in a shell as user)
scl enable devtoolset-6 bash
- Check version
gcc --version
- 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)
cd
mkdir glibc_2.14
cd glibc_2.14
wget http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.gz
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
- Install OSRM
cd
git clone https://github.com/Project-OSRM/osrm-backend.git osrm-backend
mkdir osrm-backend/build
cd osrm-backend/build
cmake .. -DENABLE_MASON=ON
make
make install
- Before running osrm-* commands export new glibc 2.14 library
export LD_LIBRARY_PATH=/opt/glibc-2.14/lib