Bulding OSRM backend on CentOS 6 - sayr777/osrm-backend GitHub Wiki
For bulding OSRM-backend on Centos 6 you must install lot of additional packages and (Important!) use gcc 4.8 or higer. This scripts download all needed software, starting gcc 4.8.2 and build osrm-backend. When you run osrm-install.sh you must enter number of threads for use in compilation process (make -j).
Save two scripts as osrm-prepare.sh and osrm-install.sh, then:
chmod +x osrm-prepare.sh
chmod +x osrm-install.sh
Then just run
./osrm-prepare.sh
./osrm-install.sh
First script adding repos and install prerequested packages, then enable devtoolset-2 to use gcc 4.8.2:
#!/bin/bash
#Preparing script
#Installing additional repositories
wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
wget -O /etc/yum.repos.d/slc6-devtoolset.repo http://linuxsoft.cern.ch/cern/devtoolset/slc6-devtoolset.repo
#Installing required packages
yum -y install gcc-c++ libxml2-devel bzip2-devel protobuf-devel cmake libzip-devel lua-devel protobuf-lite protobuf-lite-devel tbb-devel libzip tbb git python python-devel patch openmpi expat-devel --nogpgcheck
yum -y install devtoolset-2 boost-devel --nogpgcheck
#Enable devtoolset-2 for use GCC 4.8.2
scl enable devtoolset-2 bash
Second script install OSRM-binary, OSRM-backend, STXXL, BOOST, BOOST-JAM LUABIND, LUAJIT, and fix luabind bug (luabind 1.9.0 and boost 1.57 not work without fix)
#!/bin/bash
#OSRM installation script
echo "Started"
echo ""
read -p "Enter number of threads to use in compile - \"make -j\" [1]: " -e -i 1 Threads
echo ""
echo -n "Using $Threads threads"
echo ""
#Installing Boost package
cd /tmp
wget http://sourceforge.net/projects/boost/files/boost/1.57.0/boost_1_57_0.tar.bz2
tar -jxf boost_1_57_0.tar.bz2
cd boost_1_57_0/
./bootstrap.sh --prefix=/opt/osrm_infrastructure/boost_1_57_0
./b2 --prefix=/opt/osrm_infrastructure/boost_1_57_0 -j$Threads
#Installing boost-jam package
cd /tmp
wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/jblunck:/md/CentOS_CentOS-6/x86_64/boost-jam-1.46.1-10.1.x86_64.rpm
rpm -ivh boost-jam-1.46.1-10.1.x86_64.rpm
#Installing boost-build package
wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/jblunck:/md/CentOS_CentOS-6/x86_64/boost-build-1.46.1-10.1.x86_64.rpm
rpm -ivh boost-build-1.46.1-10.1.x86_64.rpm
#Installing STXXL package
cd /tmp
git clone git://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 -j$Threads && make install
cd ..
mkdir release && cd release
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/osrm_infrastructure/stxx -DBUILD_STATIC_LIBS=ON ..
make -j$Threads && make install
#Installing LUABIND package
cd /tmp
wget http://sourceforge.net/projects/luabind/files/luabind/0.9.1/luabind-0.9.1.tar.gz
tar -zxf luabind-0.9.1.tar.gz
cd luabind-0.9.1/
sed -i 's|(prefix)/lib ;|(prefix)/lib64 ;|' Jamroot
git clone https://gist.github.com/2011636.git
patch -p1 < ./2011636/luabind_boost.patch
bjam install --prefix=/opt/osrm_infrastructure/luabind-0.9.1
#Resolve trouble with connectivity of LUABIND and BOOST
sed -i 540i\ '#if BOOST_VERSION < 105700' /opt/osrm_infrastructure/luabind-0.9.1/include/luabind/object.hpp
sed -i 561i\ '#endif' /opt/osrm_infrastructure/luabind-0.9.1/include/luabind/object.hpp
#Installing LUAJIT package
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
#Installing OSM-binary package
cd /tmp
git clone https://github.com/scrosby/OSM-binary.git
cd OSM-binary
mkdir build
cd build
cmake ..
make -j$Threads
make install
#Installing OSRM package
cd /opt
wget -O Project-OSRM-4.8.1.zip https://github.com/Project-OSRM/osrm-backend/archive/v4.8.1.zip
unzip Project-OSRM-4.8.1.zip
cd osrm-backend-4.8.1
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=/tmp/OSM-binary/build/src/libosmpbf.a -DOSMPBF_INCLUDE_DIR=/tmp/OSM-binary/include -DBOOST_ROOT=/tmp/boost_1_57_0 -DBOOST_LIBRARYDIR=/tmp/boost_1_57_0/lib ..
make -j$Threads
echo ""
echo "Script finished"
Tested on fresh install of Centos 6.6.