How to Install OSRM on Ubuntu 20.04 – Open Source Routing Machine

OSRM (Open Source Routing Machine) is a super fast routing engine for OpenStreetMap (OSM) road networks. In previous tutorials, we explained the process of setting up a self-hosted OpenStreetMap tile server and how to add address lookup functionality to your map with Nominatim. This tutorial is going to show you how to add navigation functionality to your OpenStreetMap with OSRM, which provides car routing, bike routing, and walk routing.

This tutorial also works on Ubuntu 18.04.

Install OSRM on Ubuntu 20.04

Prerequisites

To follow this tutorial, you should have an OSM tile server up and running. If not, please follow the tutorial below to set up your own OSM tile server.

You should also have access to a geocoding service like Nominatim for address lookup.

Once the requirements are met, follow the instructions below to set up OSRM server.

Step 1: Build OSRM From Source

Install dependency packages.

sudo apt update

sudo apt install build-essential git cmake pkg-config doxygen libboost-all-dev libtbb-dev lua5.2 liblua5.2-dev libluabind-dev libstxxl-dev libstxxl1v5 libxml2 libxml2-dev libosmpbf-dev libbz2-dev libzip-dev libprotobuf-dev

Create the osrm user. (No need to create a password for this user.)

sudo useradd -d /srv/osrm -s /bin/bash -m osrm

Grant permissions to your own user account.

sudo apt install acl

sudo setfacl -R -m u:username:rwx /srv/osrm/

Change to the /srv/osrm/ directory.

cd /srv/osrm/

Download the OSRM source code from its Github repository.

git clone https://github.com/Project-OSRM/osrm-backend.git

Create the build directory.

mkdir build

Change to this directory and configure the build environment.

cd build

cmake /srv/osrm/osrm-backend/

Compile the source code.

make

build OSRM from source ubuntu 20.04

Install the binaries.

sudo make install

The following binaries will be installed.

  • /usr/local/bin/osrm-extract:
  • /usr/local/bin/osrm-partition:
  • /usr/local/bin/osrm-customize:
  • /usr/local/bin/osrm-contract:
  • /usr/local/bin/osrm-datastore:
  • /usr/local/bin/osrm-routed:

Step 2: Install GNU Screen

In the next step, we will need to extract road networks from OpenStreetMap, which can take a long time. Your computer might be disconnected from the Internet, so it’s recommended to use the GNU Screen utility to keep your session alive. Install screen on the Ubuntu 20.04 server:

sudo apt install screen

Then start screen:

screen

Upon the first launch, you will see an introduction text, simply press Enter to end. Then you will be able to run commands as usual.

Step 3: Generate OSRM Routing Data

Now we need to download the OpenStreetMap data and make it usable for routing. Run the following command to download the map data of the whole planet (56G) in PBF (ProtoBufBinary) format.

wget -c http://planet.openstreetmap.org/pbf/planet-latest.osm.pbf -P /srv/osrm/osrm-backend

If you want a map of an individual country/state/province/city, go to http://download.geofabrik.de. For example, download the map data of Great Britain (1.2G) with the following command.

wget -c http://download.geofabrik.de/europe/great-britain-latest.osm.pbf -P /srv/osrm/osrm-backend

BBBike.org also provides extracts of more than 200 cities and regions worldwide in different formats.

Make sure you are in the /srv/osrm/osrm-backend/ directory.

cd /srv/osrm/osrm-backend/

Extract a graph out of the OpenStreetMap data.

osrm-extract britain-and-ireland-latest.osm.pbf --threads=10

By default, it will use the car.lua profile.

Generate OSRM Routing Data ubuntu 20.04

Now you probably don’t need to do other things on your server. Since you are using Screen, you can press Ctrl+A, release those keys, and then press D key to detach from the current Screen session. You will see a message like below.

[detached from 32113.pts-1.focal]

This tells me that the previous Screen session ID is 32113. You can log out from the SSH session and even shut down your computer. Don’t worry, the osrm-extract process is still running. When you need to come back and check the progress, SSH into your server and run the following command to get the previous Screen Session ID.

screen -ls

Sample output:

There is a screen on:
	32113.pts-1.focal	(05/19/2020 03:45:29 PM)	(Detached)
1 Socket in /run/screen/S-linuxbabe.

Then you can re-attach to the previous Screen session.

screen -r 32113

This process is memory intensive. (It uses 7GB RAM on my server.) Once it’s finised, there will be a file with the same filename but with the .osrm extension. Run the following command to partition this graph recursively into cells

osrm-partition britain-and-ireland-latest.osrm

osrm-partition ubuntu 20.04

Customize the cells by calculating routing weights for all cells.

osrm-customize britain-and-ireland-latest.osrm

osrm-customize ubuntu 20.04

Now you can start the routing engine.

osrm-routed --algorithm=MLD britain-and-ireland-latest.osrm

osrm-routed ubuntu 20.04

As you can see, it listens on TCP port 5000.

Step 4: Creating a systemd service

We can manually run the OSRM routing engine with osrm-routed --algorithm=MLD britain-and-ireland-latest.osrm, but it’s more convenient to run osrm-routed as a systemd service in the background. Press Ctrl+C to stop the current osrm-routed process and create a systemd service unit file for osrm-routed with the following command.

sudo nano /etc/systemd/system/osrm-routed.service

Put the following lines into the file.

[Unit]
Description=Open Source Routing Machine
Wants=network-online.target
After=network.target network-online.target

[Service]
ExecStart=/usr/local/bin/osrm-routed --algorithm=MLD /srv/osrm/osrm-backend/britain-and-ireland-latest.osrm
User=osrm
Group=osrm
Restart=always
RestartSec=5s

[Install]
WantedBy=multi-user.target

Save and close the file. Change the ownership of the /srv/osrm/osrm-backend/ directory.

sudo chown osrm:osrm /srv/osrm/osrm-backend/ -R

Now we can start and enable the osrm-routed systemd service.

sudo systemctl start osrm-routed

sudo systemctl enable osrm-routed

Check status.

systemctl status osrm-routed

osrm-routed systemd service ubuntu 20.04

If the osrm-routed service isn’t active (running), you can run the following command to see what’s wrong.

sudo journalctl -eu osrm-routed

Step 5: Configure Apache web server

We can configure Apache web server as a reverse proxy for the osrm-routed service, so we can use a domain name to access the routing service and also enable HTTPS encryption.

Install Apache web server.

sudo apt install apache2

To use Apache as a reverse proxy, we need to enable the proxy, proxy_http and rewrite module.

sudo a2enmod proxy proxy_http rewrite

Then create a virtual host file for OSRM.

sudo nano /etc/apache2/sites-available/osrm.conf

Add the following texts into the file. Replace osrm.your-domain.com with your actual domain name and don’t forget to create DNS A record for it.

<VirtualHost *:80>
    ServerName osrm.your-domain.com

    ProxyPass / http://127.0.0.1:5000/
    ProxyPassReverse / http://127.0.0.1:5000/

    # Only allow authorizied domains to use this service.
    SetEnvIf Origin "^http(s)?://(.+\.)?(example\.com|otherdomain\.tld)$" origin_is=$0
    Header unset Access-Control-Allow-Origin
    Header always set Access-Control-Allow-Origin %{origin_is}e env=origin_is
</VirtualHost>

Save and close the file. Then enable this virtual host.

sudo a2ensite osrm.conf

Reload Apache for the changes to take effect.

sudo systemctl reload apache2

Now you can remotely access OSRM by entering the domain name (osrm.your-domain.com ) in browser address bar.

Step 6: Enable HTTPS

We can enable HTTPS by installing a free TLS certificate issued from Let’s Encrypt. In the OSM tile server setup tutorial, we have already install the Let’s Encrypt client (certbot) from the Snap store. So we just need to run the following command to obtain and install TLS certificate.

sudo /snap/bin/certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d osrm.your-domain.com

Where:

  • --apache: Use the Apache plugin.
  • --agree-tos: Agree to terms of service.
  • --redirect: Force HTTPS by 301 redirect.
  • --hsts: Add the Strict-Transport-Security header to every HTTP response. Forcing browser to always use TLS for the domain. Defends against SSL/TLS Stripping.
  • --staple-ocsp: Enables OCSP Stapling. A valid OCSP response is stapled to the certificate that the server offers during TLS.

The certificate should now be obtained and automatically installed. And you will be able to access Webmin web interface over a secure HTTPS connection.

osrm https certbot ubuntu 20.04

Step 7: Integrate OSRM with a Slippy Map

I assume your slippy map is displayed using the Leaflet JavaScript library, and you have added Nominatim geocoding service to your slippy map.

To integrate OSRM with a slippy map, we can use a plugin called Leaflet Routing Machine. First, include the Leaflet routing machine JavaScript and CSS file to your slippy map. Note that they should be placed after the main Leaflet JavaScript and the Leaflet Control Geocoder JavaScript.

<html>
  <head>
     ....
     ....
     <link rel="stylesheet" href="https://unpkg.com/leaflet-routing-machine@latest/dist/leaflet-routing-machine.css" />
     <script src="https://unpkg.com/leaflet-routing-machine@latest/dist/leaflet-routing-machine.js"></script>
 </head>
 <body>
 ....
 ....
 </body>
</html>

Next, add the following lines to the <script>...</script> snippet in the HTML body.

     L.Routing.control({
         serviceUrl: 'https://osrm.your-domain.com/route/v1',
         geocoder: L.Control.Geocoder.nominatim({serviceUrl:'https://tile.your-domain.com/nominatim/'}),
         routeWhileDragging: true
       }).addTo(map);

Like this:

<html>
  <head>
     ....
     ....
     <link rel="stylesheet" href="https://unpkg.com/leaflet-routing-machine@latest/dist/leaflet-routing-machine.css" />
     <script src="https://unpkg.com/leaflet-routing-machine@latest/dist/leaflet-routing-machine.js"></script>
 </head>
 <body>
   <div id="map"></div>
     <script>
     ....
     ....


     L.Routing.control({
         serviceUrl: 'https://osrm.your-domain.com/route/v1',
         geocoder: L.Control.Geocoder.nominatim({serviceUrl:'https://tile.your-domain.com/nominatim/'}),
         routeWhileDragging: true
       }).addTo(map);

    </script>

  </body> 
</html>

Save and close the file. Then reload the map in your web browser, you should see a control panel on the upper-right corner, where you can enter the starting address and destination address.

Install OSRM on Ubuntu 20.04

You can drag the waypoints on the map and OSRM will automatically recalculate the route.

Wrapping Up

I hope this tutorial helped you set up OSRM server on Ubuntu 20.04. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks. Take care 🙂

Rate this tutorial
[Total: 4 Average: 5]

19 Responses to “How to Install OSRM on Ubuntu 20.04 – Open Source Routing Machine

  • Hi, thanks for the other two tutorials, they work great. I had to do a bit extra to get them working in a proxmox container with ZFS, and then working with pfsense and cloudflare.

    I have been trying to get this last tutorial working, but I don’t know where to check for error information. When I try it in an empty LXC it still errors out.

    [info] Generating edge-expanded graph representation
    [info] . 10% . 20% . 30% . 40% . 50% . 60% . 70% . 80% . 90% . 100%
    [info] Node compression ratio: 0.20656
    [info] Edge compression ratio: 0.24589
    Killed
    

    The server has 256GB, the vm is allotted 128GB with a 40GB scratch an 200GB free disk space.
    Any insight appreciated, but the know-how to see what killed my poor machine would be nice.

    NOTE: I am for now on using your amazon link for all future purchases=)

  • disregard my post- delete….
    I added more memory, restarted the lxc, and stopped it from pre-rendering tiles.
    Then the process completed, but I seem to have trouble rendering tiles.
    I’ll work on this for another day and see if I can see something in journalctl.

    • tooneamelt
      3 years ago

      If you also followed the guide to set up nominatim, I then had to give permissions again to osm on gis. My server wouldn’t render after nominatim but after reapplying the osm privilege to gis, it started working again.
      The error was in renderd journalctl saying the postgres server disconnected unexpectedly

    • tooneamelt
      3 years ago

      Sorry, I missed saying you need to give permissions to osm on the gis scheme in postgres

  • tooneamelt
    3 years ago

    I’d recommend adding swap if you have the space for it, as osrm-extract can be much faster if you add threads (if you have them)

    sudo mkdir /media
    sudo dd if=/dev/zero of=/media/swapfile.img bs=1024 count=100M # 1M=1GiB, so change count to whatever you can afford from your drive
    sudo mkswap /media/swapfile.img
    sudo swapon /media/swapfile.img
    
  • [info] Parsing in progress..
    [info] input file generated by osmium/1.8.0
    [info] timestamp: 2019-09-14T20:15:02Z
    [info] Using profile api version 4
    [info] Found 3 turn restriction tags:
    [info] motorcar
    [info] motor_vehicle
    [info] vehicle
    [info] Parse relations …
    [info] Parse ways and nodes …
    [info] Using profile api version 4
    [info] Using profile api version 4
    [info] Using profile api version 4
    [info] RAM: peak bytes used: 1191161856
    [error] [exception] std::bad_alloc
    [error] Please provide more memory or consider using a larger swapfile

  • How do I change the route instructions unit to miles? I tried switching line 16270 in leaflet-routing-machine.js to ‘imperial’ but it didn’t seem to change anything.

  • Thiago Guedes
    2 years ago

    Boa tarde , fiz as configurações. Porém quando acesso no navegador esta abrindo uma pagina do apache . Poderia me ajudar?

    Obrigado

    • Xiao Guoan (Admin)
      2 years ago

      Use a real domain name instead of an IP address.

  • Hi

    I am running into fallowing issue which throws an fatal error and exits the script. I already try to find a solution via google but cant….

    This is the error …

    command: cmake /srv/osrm/osrm-backend/

    Scanning dependencies of target EXTRACTOR
    [  0%] Building CXX object CMakeFiles/EXTRACTOR.dir/src/extractor/compressed_edge_container.cpp.o
    [  2%] Building CXX object CMakeFiles/EXTRACTOR.dir/src/extractor/edge_based_graph_factory.cpp.o
    /srv/osrm/osrm-backend/src/extractor/edge_based_graph_factory.cpp:35:10: fatal error: tbb/parallel_pipeline.h: No such file or directory
       35 | #include 
    
    • I have this exact same error, and I would also like to know an answer! If you find out a solution please let me know. I have tried reinstalling tbb libraries, hardcoding it to path, etc. Nothing is working!

      • Hi i fixed my problem by

        RUNNING

            apt-get update && \
            apt-get -y --no-install-recommends install ca-certificates cmake make git gcc g++ libbz2-dev libxml2-dev wget \
            libzip-dev libboost1.74-all-dev lua5.4 liblua5.4-dev -o APT::Install-Suggests=0 -o APT::Install-Recommends=0
        

        AND

            NPROC=${BUILD_CONCURRENCY:-$(nproc)} && \
            ldconfig /usr/local/lib && \
            git clone --branch v2021.3.0 --single-branch https://github.com/oneapi-src/oneTBB.git && \
            cd oneTBB && \
            mkdir build && \
            cd build && \
            cmake -DTBB_TEST=OFF -DCMAKE_BUILD_TYPE=Release ..  && \
            cmake --build . && \
            cmake --install .
        

        AND THEN AGAIN

        cd /srv/osrm/
        git clone https://github.com/Project-OSRM/osrm-backend.git
        mkdir build
        cd build
        cmake /srv/osrm/osrm-backend/
        make
        

        Found this solution on the github page of the osrm backend
        github(.)com/Project-OSRM/osrm-backend/issues/6361

        Hope that this will help you!

    • Xiao Guoan (Admin)
      2 years ago

      Are you using Ubuntu 22.04? It currently doesn’t work.

  • please help me, I did everything as in the tutorial, but when accessing the server it gives an error 404. what to do?

  • I am receiving an error with “Linking CXX executable osrm-routed”

    Scanning dependencies of target osrm-routed
    [ 91%] Linking CXX executable osrm-routed
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::detail::sp_counted_impl_p<boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_compressor_impl<std::allocator >, std::allocator >::impl>::dispose(): error: undefined reference to ‘boost::iostreams::detail::zlib_base::reset(bool, bool)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::detail::sp_counted_impl_p<boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_compressor_impl<std::allocator >, std::allocator >::impl>::dispose(): error: undefined reference to ‘boost::iostreams::detail::zlib_base::~zlib_base()’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::iostreams::basic_gzip_compressor<std::allocator >::basic_gzip_compressor(boost::iostreams::gzip_params const&, long): error: undefined reference to ‘boost::iostreams::detail::zlib_base::zlib_base()’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::iostreams::basic_gzip_compressor<std::allocator >::basic_gzip_compressor(boost::iostreams::gzip_params const&, long): error: undefined reference to ‘boost::iostreams::detail::zlib_base::do_init(boost::iostreams::zlib_params const&, bool, void* (*)(void*, unsigned int, unsigned int), void (*)(void*, void*), void*)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::iostreams::basic_gzip_compressor<std::allocator >::basic_gzip_compressor(boost::iostreams::gzip_params const&, long): error: undefined reference to ‘boost::iostreams::zlib::best_compression’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::iostreams::basic_gzip_compressor<std::allocator >::basic_gzip_compressor(boost::iostreams::gzip_params const&, long): error: undefined reference to ‘boost::iostreams::zlib::best_speed’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::iostreams::basic_gzip_compressor<std::allocator >::basic_gzip_compressor(boost::iostreams::gzip_params const&, long): error: undefined reference to ‘boost::iostreams::detail::zlib_base::reset(bool, bool)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::iostreams::basic_gzip_compressor<std::allocator >::basic_gzip_compressor(boost::iostreams::gzip_params const&, long): error: undefined reference to ‘boost::iostreams::detail::zlib_base::~zlib_base()’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::iostreams::basic_gzip_compressor<std::allocator >::basic_gzip_compressor(boost::iostreams::gzip_params const&, long): error: undefined reference to ‘boost::iostreams::detail::zlib_base::reset(bool, bool)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::iostreams::basic_gzip_compressor<std::allocator >::basic_gzip_compressor(boost::iostreams::gzip_params const&, long): error: undefined reference to ‘boost::iostreams::detail::zlib_base::~zlib_base()’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::iostreams::detail::indirect_streambuf<boost::iostreams::basic_gzip_compressor<std::allocator >, std::char_traits, std::allocator, boost::iostreams::output>::sync_impl(): error: undefined reference to ‘boost::iostreams::detail::zlib_base::before(char const*&, char const*, char*&, char*)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::iostreams::detail::indirect_streambuf<boost::iostreams::basic_gzip_compressor<std::allocator >, std::char_traits, std::allocator, boost::iostreams::output>::sync_impl(): error: undefined reference to ‘boost::iostreams::zlib::no_flush’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::iostreams::detail::indirect_streambuf<boost::iostreams::basic_gzip_compressor<std::allocator >, std::char_traits, std::allocator, boost::iostreams::output>::sync_impl(): error: undefined reference to ‘boost::iostreams::detail::zlib_base::xdeflate(int)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::iostreams::detail::indirect_streambuf<boost::iostreams::basic_gzip_compressor<std::allocator >, std::char_traits, std::allocator, boost::iostreams::output>::sync_impl(): error: undefined reference to ‘boost::iostreams::detail::zlib_base::after(char const*&, char*&, bool)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::iostreams::detail::indirect_streambuf<boost::iostreams::basic_gzip_compressor<std::allocator >, std::char_traits, std::allocator, boost::iostreams::output>::sync_impl(): error: undefined reference to ‘boost::iostreams::zlib_error::check(int)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::iostreams::detail::indirect_streambuf<boost::iostreams::basic_gzip_compressor<std::allocator >, std::char_traits, std::allocator, boost::iostreams::output>::sync_impl(): error: undefined reference to ‘boost::iostreams::zlib::stream_end’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::iostreams::detail::indirect_streambuf<boost::iostreams::basic_gzip_compressor<std::allocator >, std::char_traits, std::allocator, boost::iostreams::output>::overflow(int): error: undefined reference to ‘boost::iostreams::detail::zlib_base::before(char const*&, char const*, char*&, char*)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::iostreams::detail::indirect_streambuf<boost::iostreams::basic_gzip_compressor<std::allocator >, std::char_traits, std::allocator, boost::iostreams::output>::overflow(int): error: undefined reference to ‘boost::iostreams::zlib::no_flush’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::iostreams::detail::indirect_streambuf<boost::iostreams::basic_gzip_compressor<std::allocator >, std::char_traits, std::allocator, boost::iostreams::output>::overflow(int): error: undefined reference to ‘boost::iostreams::detail::zlib_base::xdeflate(int)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::iostreams::detail::indirect_streambuf<boost::iostreams::basic_gzip_compressor<std::allocator >, std::char_traits, std::allocator, boost::iostreams::output>::overflow(int): error: undefined reference to ‘boost::iostreams::detail::zlib_base::after(char const*&, char*&, bool)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::iostreams::detail::indirect_streambuf<boost::iostreams::basic_gzip_compressor<std::allocator >, std::char_traits, std::allocator, boost::iostreams::output>::overflow(int): error: undefined reference to ‘boost::iostreams::zlib_error::check(int)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function boost::iostreams::detail::indirect_streambuf<boost::iostreams::basic_gzip_compressor<std::allocator >, std::char_traits, std::allocator, boost::iostreams::output>::overflow(int): error: undefined reference to ‘boost::iostreams::zlib::stream_end’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function long boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_compressor_impl<std::allocator >, std::allocator >::read<boost::iostreams::detail::linked_streambuf<char, std::char_traits > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits >&, char*, long): error: undefined reference to ‘boost::iostreams::detail::zlib_base::before(char const*&, char const*, char*&, char*)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function long boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_compressor_impl<std::allocator >, std::allocator >::read<boost::iostreams::detail::linked_streambuf<char, std::char_traits > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits >&, char*, long): error: undefined reference to ‘boost::iostreams::zlib::no_flush’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function long boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_compressor_impl<std::allocator >, std::allocator >::read<boost::iostreams::detail::linked_streambuf<char, std::char_traits > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits >&, char*, long): error: undefined reference to ‘boost::iostreams::detail::zlib_base::xdeflate(int)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function long boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_compressor_impl<std::allocator >, std::allocator >::read<boost::iostreams::detail::linked_streambuf<char, std::char_traits > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits >&, char*, long): error: undefined reference to ‘boost::iostreams::detail::zlib_base::after(char const*&, char*&, bool)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function long boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_compressor_impl<std::allocator >, std::allocator >::read<boost::iostreams::detail::linked_streambuf<char, std::char_traits > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits >&, char*, long): error: undefined reference to ‘boost::iostreams::zlib_error::check(int)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function long boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_compressor_impl<std::allocator >, std::allocator >::read<boost::iostreams::detail::linked_streambuf<char, std::char_traits > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits >&, char*, long): error: undefined reference to ‘boost::iostreams::zlib::stream_end’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function long boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_compressor_impl<std::allocator >, std::allocator >::read<boost::iostreams::detail::linked_streambuf<char, std::char_traits > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits >&, char*, long): error: undefined reference to ‘boost::iostreams::detail::zlib_base::before(char const*&, char const*, char*&, char*)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function long boost::iostreams::symmetric_filter<boost::iostreams::detail::zlib_compressor_impl<std::allocator >, std::allocator >::read<boost::iostreams::detail::linked_streambuf<char, std::char_traits > >(boost::iostreams::detail::linked_streambuf<char, std::char_traits >&, char*, long): error: undefined reference to ‘boost::iostreams::zlib::finish’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function void boost::iostreams::basic_gzip_compressor<std::allocator >::close<boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits > > >(boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits > >&, std::_Ios_Openmode): error: undefined reference to ‘boost::iostreams::zlib::finish’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function void boost::iostreams::basic_gzip_compressor<std::allocator >::close<boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits > > >(boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits > >&, std::_Ios_Openmode): error: undefined reference to ‘boost::iostreams::detail::zlib_base::xdeflate(int)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function void boost::iostreams::basic_gzip_compressor<std::allocator >::close<boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits > > >(boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits > >&, std::_Ios_Openmode): error: undefined reference to ‘boost::iostreams::detail::zlib_base::after(char const*&, char*&, bool)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function void boost::iostreams::basic_gzip_compressor<std::allocator >::close<boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits > > >(boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits > >&, std::_Ios_Openmode): error: undefined reference to ‘boost::iostreams::zlib_error::check(int)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function void boost::iostreams::basic_gzip_compressor<std::allocator >::close<boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits > > >(boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits > >&, std::_Ios_Openmode): error: undefined reference to ‘boost::iostreams::zlib::stream_end’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function void boost::iostreams::basic_gzip_compressor<std::allocator >::close<boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits > > >(boost::iostreams::non_blocking_adapter<boost::iostreams::detail::linked_streambuf<char, std::char_traits > >&, std::_Ios_Openmode): error: undefined reference to ‘boost::iostreams::detail::zlib_base::reset(bool, bool)’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function osrm::server::Connection::compress_buffers(std::vector<char, std::allocator > const&, osrm::server::http::compression_type): error: undefined reference to ‘boost::iostreams::zlib::deflated’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function osrm::server::Connection::compress_buffers(std::vector<char, std::allocator > const&, osrm::server::http::compression_type): error: undefined reference to ‘boost::iostreams::zlib::default_strategy’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function osrm::server::Connection::compress_buffers(std::vector<char, std::allocator > const&, osrm::server::http::compression_type): error: undefined reference to ‘boost::iostreams::zlib::default_compression’
    CMakeFiles/SERVER.dir/src/server/connection.cpp.o:connection.cpp:function osrm::server::Connection::compress_buffers(std::vector<char, std::allocator > const&, osrm::server::http::compression_type): error: undefined reference to ‘boost::iostreams::zlib::best_speed’
    collect2: error: ld returned 1 exit status
    make[2]: *** [CMakeFiles/osrm-routed.dir/build.make:151: osrm-routed] Error 1
    make[1]: *** [CMakeFiles/Makefile2:383: CMakeFiles/osrm-routed.dir/all] Error 2
    make: *** [Makefile:152: all] Error 2

  • Please help with this, after make command (UBUNTU 20.04)

    # make
    Scanning dependencies of target EXTRACTOR
    [ 4%] Building …….

    and:

    In file included from /usr/include/boost/geometry/strategies/geographic/distance.hpp:38,
                     from /usr/include/boost/geometry/strategies/strategies.hpp:113,
                     from /usr/include/boost/geometry/geometry.hpp:49,
                     from /usr/include/boost/geometry.hpp:17,
                     from /srv/osrm/osrm-backend/include/extractor/location_dependent_data.hpp:5,
                     from /srv/osrm/osrm-backend/src/extractor/location_dependent_data.cpp:1:
    /srv/osrm/osrm-backend/src/extractor/location_dependent_data.cpp: In instantiation of ‘osrm::extractor::LocationDependentData::loadLocationDependentData(const boost::filesystem::path&, std::vector<std::pair<boost::geometry::model::box<boost::geometry::model::d2::point_xy<double, boost::geometry::cs::spherical_equatorial > >, long unsigned int> >&):: [with auto:3 = rapidjson::GenericArray<false, rapidjson::GenericValue<rapidjson::UTF8 > >; auto:4 = long unsigned int]:: [with auto:6 = rapidjson::GenericArray<false, rapidjson::GenericValue<rapidjson::UTF8 > >; osrm::extractor::LocationDependentData::box_t = boost::geometry::model::box<boost::geometry::model::d2::point_xy<double, boost::geometry::cs::spherical_equatorial > >]’:
    /srv/osrm/osrm-backend/src/extractor/location_dependent_data.cpp:129:13:   required from ‘osrm::extractor::LocationDependentData::loadLocationDependentData(const boost::filesystem::path&, std::vector<std::pair<boost::geometry::model::box<boost::geometry::model::d2::point_xy<double, boost::geometry::cs::spherical_equatorial > >, long unsigned int> >&):: [with auto:3 = rapidjson::GenericArray<false, rapidjson::GenericValue<rapidjson::UTF8 > >; auto:4 = long unsigned int]’
    /srv/osrm/osrm-backend/src/extractor/location_dependent_data.cpp:180:56:   required from here
    /usr/include/boost/geometry/geometries/point_xy.hpp:46:7: note: ‘using point_t = class boost::geometry::model::d2::point_xy<double, boost::geometry::cs::spherical_equatorial >’ {aka ‘class boost::geometry::model::d2::point_xy<double, boost::geometry::cs::spherical_equatorial >’} has no user-provided default constructor
       46 | class point_xy : public model::point
          |       ^~~~~~~~
    /usr/include/boost/geometry/geometries/point_xy.hpp:52:5: note: constructor is not user-provided because it is explicitly defaulted in the class body
       52 |     point_xy() = default;
          |     ^~~~~~~~
    In file included from /usr/include/boost/geometry/geometries/helper_geometry.hpp:24,
                     from /usr/include/boost/geometry/strategies/spherical/envelope_segment.hpp:36,
                     from /usr/include/boost/geometry/algorithms/detail/envelope/segment.hpp:30,
                     from /usr/include/boost/geometry/algorithms/detail/disjoint/segment_box.hpp:33,
                     from /usr/include/boost/geometry/strategies/spherical/disjoint_segment_box.hpp:30,
                     from /usr/include/boost/geometry/strategies/spherical/intersection.hpp:45,
                     from /usr/include/boost/geometry/strategies/intersection_strategies.hpp:30,
                     from /usr/include/boost/geometry/strategies/strategies.hpp:39,
                     from /usr/include/boost/geometry/geometry.hpp:49,
                     from /usr/include/boost/geometry.hpp:17,
                     from /srv/osrm/osrm-backend/include/extractor/location_dependent_data.hpp:5,
                     from /srv/osrm/osrm-backend/src/extractor/location_dependent_data.cpp:1:
    /usr/include/boost/geometry/geometries/point.hpp:213:20: note: and the implicitly-defined constructor does not initialize ‘double boost::geometry::model::point<double, 2, boost::geometry::cs::spherical_equatorial >::m_values [2]’
      213 |     CoordinateType m_values[DimensionCount];
          |  
    
    In file included from /usr/include/boost/geometry/strategies/geographic/distance.hpp:38,
                     from /usr/include/boost/geometry/strategies/strategies.hpp:113,
                     from /usr/include/boost/geometry/geometry.hpp:49,
                     from /usr/include/boost/geometry.hpp:17,
                     from /srv/osrm/osrm-backend/include/extractor/location_dependent_data.hpp:5,
                     from /srv/osrm/osrm-backend/src/extractor/location_dependent_data.cpp:1:
    /srv/osrm/osrm-backend/src/extractor/location_dependent_data.cpp: In instantiation of ‘osrm::extractor::LocationDependentData::loadLocationDependentData(const boost::filesystem::path&, std::vector<std::pair<boost::geometry::model::box<boost::geometry::model::d2::point_xy<double, boost::geometry::cs::spherical_equatorial > >, long unsigned int> >&):: [with auto:3 = rapidjson::GenericArray<false, rapidjson::GenericValue<rapidjson::UTF8 > >; auto:4 = long unsigned int]:: [with auto:6 = rapidjson::GenericArray<false, rapidjson::GenericValue<rapidjson::UTF8 > >; osrm::extractor::LocationDependentData::box_t = boost::geometry::model::box<boost::geometry::model::d2::point_xy<double, boost::geometry::cs::spherical_equatorial > >]’:
    /srv/osrm/osrm-backend/src/extractor/location_dependent_data.cpp:129:13:   required from ‘osrm::extractor::LocationDependentData::loadLocationDependentData(const boost::filesystem::path&, std::vector<std::pair<boost::geometry::model::box<boost::geometry::model::d2::point_xy<double, boost::geometry::cs::spherical_equatorial > >, long unsigned int> >&):: [with auto:3 = rapidjson::GenericArray<false, rapidjson::GenericValue<rapidjson::UTF8 > >; auto:4 = long unsigned int]’
    /srv/osrm/osrm-backend/src/extractor/location_dependent_data.cpp:180:56:   required from here
    /usr/include/boost/geometry/geometries/point_xy.hpp:46:7: note: ‘using point_t = class boost::geometry::model::d2::point_xy<double, boost::geometry::cs::spherical_equatorial >’ {aka ‘class boost::geometry::model::d2::point_xy<double, boost::geometry::cs::spherical_equatorial >’} has no user-provided default constructor
       46 | class point_xy : public model::point
    

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here