3

In Mac OS X, when using LLVM LD to link some C code (which will result in a shared library called libA.so) that has a dependency to a shared library called libX.so, the absolute full path of libX.so is included in the list of shared libraries that libA.so needs. In other words, when doing ldd libA.so the following is shown:

(...)
/Users/foo/workspace/libX.so (compatibility version 0.0.0, current version 0.0.0)
(...)

How can one link the C code so that only the relative path of libX.so is included? In other words, when doing ldd libA.so the following is shown instead:

(...)
./workspace/libX.so (compatibility version 0.0.0, current version 0.0.0)
(...)
compor
  • 2,239
  • 1
  • 19
  • 29
  • duplicate of https://stackoverflow.com/questions/13769141/can-i-change-rpath-in-an-already-compiled-binary – compor Jan 31 '18 at 21:53
  • @compor the question you're linking is `ELF` linux specific and so is the accepted answer's `chrpath` tool. – Kamil.S Feb 11 '18 at 15:06
  • 1
    @Kamil.S yes, although [it's](https://stackoverflow.com/questions/13769141/can-i-change-rpath-in-an-already-compiled-binary) the most relevant and the accepted answer has a comment for mac uses mentioning `install_name_tool` with the use of the `-rpath` option. It just takes a bit of extra time to search properly. – compor Feb 11 '18 at 15:55
  • @compor Perhaps adding `macos` tag to the question would make it more explicit and easily findable. I gotta admit I did initially miss the comment you're referring to. – Kamil.S Feb 11 '18 at 16:05

0 Answers0