Skip to content

Can't build shared libraries on macOS #6954

Open
@mattwigway

Description

@mattwigway

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 const&, osrm::extractor::detail::EdgeBasedNodeDataContainerImpl<(osrm::storage::Ownership)0> const&, std::__1::vector> const&, osrm::extractor::CompressedEdgeContainer const&, std::__1::unordered_set, std::__1::equal_to, std::__1::allocator> const&, osrm::extractor::NodeRestrictionMap const&, osrm::extractor::WayRestrictionMap const&, osrm::extractor::detail::NameTableImpl<(osrm::storage::Ownership)0> const&, osrm::extractor::SuffixTable const&, std::__1::tuple>, std::__1::vector>> const&, osrm::util::ConcurrentIDMap>, unsigned short, std::__1::hash>>>&, osrm::util::ConcurrentIDMap>&, osrm::guidance::detail::TurnDataContainerImpl<(osrm::storage::Ownership)2>&, std::__1::vector>&, osrm::util::ConcurrentIDMap>&, osrm::util::ConcurrentIDMap>&, 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions