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

Link libosrm_guidance correctly and work around circular dependencies

Open mattwigway opened this issue 1 year ago • 20 comments

Fixes #6954

Issue

Building shared libraries on macOS fails, because there is no target_link_libraries call for osrm_guidance to tell it what external and internal libraries to link against. This works on Linux because the linker assumes undefined symbols will be defined at runtime, but macOS checks that the symbols are defined at link time. This PR adds the target_link_libraries call.

This creates another problem in that there is a circular dependency between osrm_guidance and osrm_extract. osrm_guidance calls a lot of functions from osrm_extract, and osrm_extract only calls two from osrm_guidance. So I fix this by specifying linker options to tell the linker to resolve those two functions at runtime. I've only tested this with clang on macOS, but I think it should work on other platforms as well. It looks like the CI currently doesn't try to build shared libraries on any platform, perhaps we should change that?

Tasklist

Requirements / Relations

None

mattwigway avatar Jun 17 '24 21:06 mattwigway