-
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
mkdir -p build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
sudo cmake --build . --target install
###Ubuntu
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 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.
save following as script and run:
#!/bin/bash
OS=$(uname)
ARCH=$(uname -m)
PREFIX=/opt/osrm_infrastructure
mkdir packages 2> /dev/null
cd packages
wget http://www.cmake.org/files/v2.8/cmake-2.8.12.2.tar.gz
wget https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.bz2
wget http://sourceforge.net/projects/stxxl/files/stxxl/1.3.1/stxxl-1.3.1.tar.gz
wget http://sourceforge.net/projects/boost/files/boost/1.55.0/boost_1_55_0.tar.bz2
wget http://luajit.org/download/LuaJIT-2.0.2.tar.gz
git clone https://github.com/scrosby/OSM-binary.git OSM-binary.git
wget -O Project-OSRM-0.3.7.zip https://github.com/Project-OSRM/osrm-backend/archive/v0.3.7.zip
cd ..
function run() {
CMD=$1
eval $CMD
if [[ $? -ne 0 ]]; then
echo "CMD: '$CMD' Failed"
exit 1
fi
echo "CMD: '$CMD' ... Success"
}
DIR=$(pwd)
if [[ ! -d ${PREFIX} ]]; then
echo "Dir: '${PREFIX}' does not exist"
run "mkdir ${PREFIX} 2>/dev/null"
fi
if [[ ! -w ${PREFIX} ]]; then
echo "Couldn't write to: '${PREFIX}'"
exit 1
fi
NAME="cmake-2.8.12.2"
run "cd /tmp"
rm -rf /tmp/$NAME
run "tar -zxf $DIR/packages/${NAME}.tar.gz"
run "cd $NAME"
run "./configure --prefix=$PREFIX"
run "make -j4"
run "make install"
NAME="protobuf-2.5.0"
run "cd /tmp"
rm -rf /tmp/$NAME
run "tar -jxf $DIR/packages/${NAME}.tar.bz2"
run "cd $NAME"
run "./configure --prefix=$PREFIX/$NAME"
run "make -j4"
run "make install"
NAME="boost_1_55_0"
run "cd /tmp"
rm -rf /tmp/$NAME
run "tar -jxf $DIR/packages/${NAME}.tar.bz2"
run "cd $NAME"
run "./bootstrap.sh --prefix=$PREFIX/$NAME"
run "./b2 install --prefix=$PREFIX/$NAME"
NAME="stxxl-1.3.1"
run "cd /tmp"
rm -rf /tmp/$NAME
run "tar -zxf $DIR/packages/${NAME}.tar.gz"
run "cd $NAME"
run "make library_g++"
run "mkdir -p $PREFIX/$NAME"
run "cp -r /tmp/$NAME/lib $PREFIX/$NAME/"
run "cp -r /tmp/$NAME/include $PREFIX/$NAME/include"
export BOOST_ROOT=/tmp/boost_1_55_0
NAME="luabind-0.9.1"
run "cd /tmp"
rm -rf /tmp/$NAME
run "tar -zxf $DIR/packages/${NAME}.tar.gz"
run "cd $NAME"
# Boost rule doesn't look in lib64 by default
run "sed -i 's|(prefix)/lib ;|(prefix)/lib64 ;|' Jamroot"
run "/tmp/boost_1_55_0/bjam --prefix=$PREFIX/$NAME install"
NAME="LuaJIT-2.0.2"
run "cd /tmp"
rm -rf /tmp/$NAME
run "tar -zxf $DIR/packages/${NAME}.tar.gz"
run "cd $NAME"
run "sed -i 's|PREFIX=.*/usr/local|PREFIX=$PREFIX/$NAME|' Makefile"
run "make install"
export PATH=$PREFIX/bin:$PREFIX/protobuf-2.5.0/bin:$PATH
NAME="OSM-binary"
run "cd /tmp"
rm -rf /tmp/$NAME
run "mkdir -p /tmp/$NAME"
run "cp -r $DIR/packages/${NAME}.git/* /tmp/$NAME/"
run "cd $NAME"
run "cmake -DPROTOBUF_LIBRARY=$PREFIX/protobuf-2.5.0/lib/libprotobuf.so -DPROTOBUF_LITE_LIBRARY=$PREFIX/protobuf-2.5.0/lib/libprotobuf-lite.so -DPROTOBUF_INCLUDE_DIR=$PREFIX/protobuf-2.5.0/include -DCMAKE_INSTALL_PREFIX=$PREFIX/$NAME ."
run "make install"
NAME="Project-OSRM-0.3.7"
run "cd /tmp"
rm -rf /tmp/$NAME
run "unzip $DIR/packages/${NAME}.zip"
if [[ -n $NAME ]]; then
rm -rf $PREFIX/$NAME
fi
run "mkdir -p /opt/$NAME"
run "cd /opt/$NAME"
run "sed -i 's| -pedantic||' /tmp/$NAME/CMakeLists.txt"
run "cmake -DBOOST_LIBRARYDIR=$PREFIX/boost_1_55_0/lib -DLUABIND_LIBRARIES=$PREFIX/luabind-0.9.1/lib -DLUABIND_LIBRARY=$PREFIX/luabind-0.9.1/lib/libluabindd.so -DLUABIND_INCLUDE_DIR=$PREFIX/luabind-0.9.1/include -DSTXXL_LIBRARY=$PREFIX/stxxl-1.3.1/lib/libstxxl.a -DSTXXL_INCLUDE_DIR=$PREFIX/stxxl-1.3.1/include -DLUAJIT_LIBRARIES=$PREFIX/LuaJIT-2.0.2/lib -DLUAJIT_INCLUDE_DIR=$PREFIX/LuaJIT-2.0.2/include -DPROTOBUF_LIBRARY=$PREFIX/protobuf-2.5.0/lib/libprotobuf.so -DPROTOBUF_INCLUDE_DIR=$PREFIX/protobuf-2.5.0/include -DOSMPBF_LIBRARY=$PREFIX/OSM-binary/lib/libosmpbf.a -DOSMPBF_INCLUDE_DIR=$PREFIX/OSM-binary/include /tmp/${NAME}/"
run "make"
yum install epel-release
yum install wget
yum install libxml2-devel boost-devel boost-regex bzip2-devel \
libzip-devel protobuf-devel protobuf-lite protobuf-lite-devel \
lua-devel.x86_64 cmake boost-build boost-jam tbb-devel
yum install patch openmpi
cd /tmp
git clone http://github.com/stxxl/stxxl.git
cd stxxl
mkdir debug
cd debug
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/opt/osrm_infrastructure/stxx -DBUILD_STATIC_LIBS=ON ..
make -j4 && make install
cd..
mkdir release; cd release
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/osrm_infrastructure/stxx - DBUILD_STATIC_LIBS=ON ..
make -j4 && make install
cd /tmp
wget http://sourceforge.net/projects/luabind/files/luabind/0.9.1/luabind-0.9.1.tar.gz
tar -zxvf luabind-0.9.1.tar.gz
cd luabind-0.9.1/
vi Jamroot
Change this line local lib = $(prefix)/lib ;
to look like this:
local lib = $(prefix)/lib64 ;
git clone https://gist.github.com/2011636.git
patch -p1 < ./2011636/luabind_boost.patch
bjam install --prefix=/opt/osrm_infrastructure/luabind-0.9.1
cd /tmp
wget http://luajit.org/download/LuaJIT-2.0.2.tar.gz
tar -zxvf LuaJIT-2.0.2.tar.gz
cd LuaJIT-2.0.2
make install PREFIX=/opt/osrm_infrastructure/LuaJIT-2.0.2
cd /tmp
git clone https://github.com/scrosby/OSM-binary.git
cd OSM-binary
mkdir build
cd build
cmake ..
make
make install
cd /opt
wget -O Project-OSRM-0.3.7.zip https://github.com/Project-OSRM/osrm-backend/archive/v0.3.7.zip
unzip v0.3.7.zip
cd osrm-backend
sed -i 's| -pedantic||' CMakeLists.txt
mkdir build; cd build
cmake -DLUABIND_INCLUDE_DIR=/opt/osrm_infrastructure/luabind-0.9.1/include -DLUABIND_LIBRARY=/opt/osrm_infrastructure/luabind-0.9.1/lib/libluabindd.so \
-DLUAJIT_LIBRARIES=/opt/osrm_infrastructure/LuaJIT-2.0.2/lib/libluajit-5.1.so -DLUAJIT_INCLUDE_DIR=/opt/osrm_infrastructure/LuaJIT-2.0.2/include/ \
-DSTXXL_LIBRARY=/opt/osrm_infrastructure/stxx/lib/libstxxl.a -DSTXXL_INCLUDE_DIR=/opt/osrm_infrastructure/stxx/include -DOSMPBF_LIBRARY=/usr/local/lib/libosmpbf.a -DOSMPBF_INCLUDE_DIR=/usr/local/include/ -DBOOST_LIBRARYDIR=/usr/lib64 ..