osrm-backend icon indicating copy to clipboard operation
osrm-backend copied to clipboard

Can't build shared libraries on macOS

Open mattwigway opened this issue 1 year ago • 0 comments

Issue

The OSRM build errors when attempting to build with -DBUILD_SHARED_LIBS=on on macOS. Specifically, there are undefined symbols when linking libosrm_guidance. We get this error:

Undefined symbol error
[ 82%] Linking CXX shared library libosrm_guidance.dylib
Undefined symbols for architecture arm64:
  "tbb::detail::r1::initialize(tbb::detail::d1::task_group_context&)", referenced from:
      osrm::guidance::annotateTurns(osrm::util::DynamicGraph<:util::nodebasededgedata> const&, osrm::extractor::detail::EdgeBasedNodeDataContainerImpl const&, std::__1::vector<:util::coordinate std::__1::allocator>> const&, osrm::extractor::CompressedEdgeContainer const&, std::__1::unordered_set, std::__1::equal_to, std::__1::allocator> const&, osrm::extractor::NodeRestrictionMap<:extractor::unconditionalonly> const&, osrm::extractor::WayRestrictionMap const&, osrm::extractor::detail::NameTableImpl const&, osrm::extractor::SuffixTable const&, std::__1::tuple<:__1::vector int std::__1::allocator>>, std::__1::vector>> const&, osrm::util::ConcurrentIDMap<:__1::vector short std::__1::allocator>>, unsigned short, std::__1::hash<:__1::vector short std::__1::allocator>>>>&, osrm::util::ConcurrentIDMap<:util::guidance::lanetupleidpair unsigned short std::__1::hash>>&, osrm::guidance::detail::TurnDataContainerImpl&, std::__1::vector>&, osrm::util::ConcurrentIDMap<:util::guidance::bearingclass unsigned int std::__1::hash>>&, osrm::util::ConcurrentIDMap<:util::guidance::entryclass unsigned short std::__1::hash>>&, unsigned int&) in guidance_processing.cpp.o
...many more, github says I can't have a comment that long...

I believe the issue is that there is no target_link_libraries for osrm_guidance so it doesn't know where to find the symbols. This works fine on Linux, as on Linux the linker just (dangerously) assumes that any undefined symbols at link-time will be available at runtime. The macOS linker does not. I have a patch to fix this, will submit a PR shortly.

Steps to reproduce

  • Clone master
mkdir build
cd build
cmake .. -DBUILD_SHARED_LIBS=ON
cmake --build .

Specifications

Please provide details of your development environment.

  • macOS 14.5
  • Apple M1
  • AppleClang 15.0.0

mattwigway avatar Jun 17 '24 21:06 mattwigway