Osrm-backend: Can't compile on Linux Mint 19

Created on 16 Jul 2018  Β·  7Comments  Β·  Source: Project-OSRM/osrm-backend

Hi, as the title says, I am not able to compile osrm running Linux Mint 19.
cmake ..
from the build directory went fine.
However, when running

[ 28%] Building CXX object CMakeFiles/EXTRACTOR.dir/src/extractor/extraction_containers.cpp.o
In file included from /usr/include/linux/aio_abi.h:31:0,
from /usr/include/stxxl/bits/io/linuxaio_queue.h:21,
from /usr/include/stxxl/bits/io/disk_queues.h:26,
from /usr/include/stxxl/bits/mng/buf_writer.h:20,
from /usr/include/stxxl/bits/mng/buf_ostream.h:17,
from /usr/include/stxxl/bits/containers/vector.h:32,
from /usr/include/stxxl/vector:14,
from /home/lbedogni/repo/osrm-backend/include/extractor/extraction_containers.hpp:10,
from /home/lbedogni/repo/osrm-backend/src/extractor/extraction_containers.cpp:1:
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:20:20: error: expected β€˜)’ before numeric constant
template class RangeTable;
^
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:20:20: error: expected β€˜>’ before numeric constant
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:20:20: error: expected unqualified-id before β€˜)’ token
template class RangeTable;
^
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:22:20: error: expected β€˜)’ before numeric constant
template
^
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:22:20: error: expected β€˜>’ before numeric constant
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:22:20: error: expected unqualified-id before β€˜)’ token
template
^
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:25:20: error: expected β€˜)’ before numeric constant
template
^
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:25:20: error: expected β€˜>’ before numeric constant
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:25:20: error: expected unqualified-id before β€˜)’ token
template
^
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:37:20: error: expected β€˜)’ before numeric constant
template class RangeTable
^
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:37:20: error: expected β€˜>’ before numeric constant
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:37:20: error: expected unqualified-id before β€˜)’ token
template class RangeTable
^
In file included from /home/lbedogni/repo/osrm-backend/src/extractor/extraction_containers.cpp:5:0:
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:185:2: warning: extra β€˜;’ [-Wpedantic]
};
^
In file included from /usr/include/linux/aio_abi.h:31:0,
from /usr/include/stxxl/bits/io/linuxaio_queue.h:21,
from /usr/include/stxxl/bits/io/disk_queues.h:26,
from /usr/include/stxxl/bits/mng/buf_writer.h:20,
from /usr/include/stxxl/bits/mng/buf_ostream.h:17,
from /usr/include/stxxl/bits/containers/vector.h:32,
from /usr/include/stxxl/vector:14,
from /home/lbedogni/repo/osrm-backend/include/extractor/extraction_containers.hpp:10,
from /home/lbedogni/repo/osrm-backend/src/extractor/extraction_containers.cpp:1:
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:187:20: error: expected β€˜)’ before numeric constant
template
^
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:187:20: error: expected β€˜>’ before numeric constant
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:187:20: error: expected unqualified-id before β€˜)’ token
template
^
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:202:20: error: expected β€˜)’ before numeric constant
template
^
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:202:20: error: expected β€˜>’ before numeric constant
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:202:20: error: expected unqualified-id before β€˜)’ token
template
^
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:218:20: error: expected β€˜)’ before numeric constant
template
^
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:218:20: error: expected β€˜>’ before numeric constant
/home/lbedogni/repo/osrm-backend/include/util/range_table.hpp:218:20: error: expected unqualified-id before β€˜)’ token
template
^
/home/lbedogni/repo/osrm-backend/src/extractor/extraction_containers.cpp: In member function β€˜void osrm::extractor::ExtractionContainers::WriteNames(const string&) const’:
/home/lbedogni/repo/osrm-backend/src/extractor/extraction_containers.cpp:118:11: error: β€˜RangeTable’ is not a member of β€˜osrm::util’
util::RangeTable<> name_index_range(name_lengths);
^~~~
/home/lbedogni/repo/osrm-backend/src/extractor/extraction_containers.cpp:118:22: error: expected primary-expression before β€˜>’ token
util::RangeTable<> name_index_range(name_lengths);
^
/home/lbedogni/repo/osrm-backend/src/extractor/extraction_containers.cpp:118:24: error: β€˜name_index_range’ was not declared in this scope
util::RangeTable<> name_index_range(name_lengths);
^
~~~
/home/lbedogni/repo/osrm-backend/src/extractor/extraction_containers.cpp:118:24: note: suggested alternative: β€˜file_dedupe_range’
util::RangeTable<> name_index_range(name_lengths);
^
~~~~~
file_dedupe_range
CMakeFiles/EXTRACTOR.dir/build.make:110: recipe for target 'CMakeFiles/EXTRACTOR.dir/src/extractor/extraction_containers.cpp.o' failed
make[2]: * [CMakeFiles/EXTRACTOR.dir/src/extractor/extraction_containers.cpp.o] Error 1
CMakeFiles/Makefile2:136: recipe for target 'CMakeFiles/EXTRACTOR.dir/all' failed
make[1]:
[CMakeFiles/EXTRACTOR.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *
* [all] Error 2

Most helpful comment

@GregersP Thanks! It seems like that did the trick when trying to compile osrm-backend v5.22.0 with -DENABLE_STXXL=On on Ubuntu 18.04. I needed to add the line:
#undef BLOCK_SIZE
just under the include statements in two files: /include/util/range_table.hpp and /include/util/indexed_data.hpp

All 7 comments

I encountered the same error when compiling osrm v5.4.3 on Ubuntu 18.04. Did you resolve it?

After some searching, it seems caused by linux/fs.h defined a c++ macro BLOCK_SIZE, and then in osrm include/util/range_table.hpp 22 line template <unsigned BLOCK_SIZE = 16, ... the marco expand which cause above error.

PS: linux/fs.h include path is (reverse):

In file included from /usr/include/linux/aio_abi.h:31:0,
from /usr/include/stxxl/bits/io/linuxaio_queue.h:21,
from /usr/include/stxxl/bits/io/disk_queues.h:26,
from /usr/include/stxxl/bits/mng/buf_writer.h:20,
from /usr/include/stxxl/bits/mng/buf_ostream.h:17,
from /usr/include/stxxl/bits/containers/vector.h:32,
from /usr/include/stxxl/vector:14,
from /home/lbedogni/repo/osrm-backend/include/extractor/extraction_containers.hpp:10,

And aio_abi.h is changed to include linux/fs.h only after kernel v4.14: https://github.com/torvalds/linux/blame/864af0d40cdc82b705e3ca79cf2a57be900954b1/include/uapi/linux/aio_abi.h#L31

For anyone else stumbling upon this, it can be backported to 4.9.1 by this patch

--- a/data_structures/range_table.hpp
+++ b/data_structures/range_table.hpp
@@ -34,6 +34,8 @@

 #include <fstream>
 #include <array>
+// NOTE: BLOCK_SIZE defined as a macro in <linux/fs.h> (included by <linux/aio_abi.h> after kernel v4.14)
+#undef BLOCK_SIZE
 /*
  * These pre-declarations are needed because parsing C++ is hard
  * and otherwise the compiler gets confused.

@GregersP Thanks! It seems like that did the trick when trying to compile osrm-backend v5.22.0 with -DENABLE_STXXL=On on Ubuntu 18.04. I needed to add the line:
#undef BLOCK_SIZE
just under the include statements in two files: /include/util/range_table.hpp and /include/util/indexed_data.hpp

@aecoleman I am compiling osrm v5.3.0 on ubuntu 18.4, but applying your solution didn't fix it. Could you please advise on this?

@adhamenaya Sorry, I have not attempted to compile v5.3.0. I vaguely recall there being some changes between 5.0 and 5.22 that involved default build parameters, but I don't remember for sure what those were. My two recommendations would be (in order of preference):

  • Try again with v5.22.0.
  • Find "BLOCK_SIZE" in files and add #undef BLOCK_SIZE just under the include statements in all .hpp files where it is present.

@aecoleman thanks for your reply. I manage to fix it by renaming BLOCK_SIZE to BLOCK_SIZE2 in file /include/util/range_table.hpp. Do you think there are any side effects? :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ltsstar picture ltsstar  Β·  5Comments

davidbarre picture davidbarre  Β·  4Comments

koussaimb picture koussaimb  Β·  4Comments

Bardo-Konrad picture Bardo-Konrad  Β·  3Comments

zifeo picture zifeo  Β·  3Comments