Recursive RPATH in macOS

Viewed 462

The directory structure of a framework is like this:

   fw.framework
      Versions
         A
            fw
            Libraries
               a.dylib
               b.dylib
         Current -> A
      Libraries -> Versions/Current/Libraries
      fw -> Versions/Current/fw

Dependencies:

  • fw links to a.dylib
  • a.dylib links to b.dylib

a.dylib and b.dylib have the install name @rpath/a.dylib and @rpath/b.dylib.

The RPATH of fw is set to @loader_path/Libraries, so that it can find a.dylib.

But the RPATH of a.dylib is set to @loader_path, because its dependency b.dylib is in the same directory.

Will this work? Will the linker use the RPATH of a.dylib (and not the one of fw, when recursively linking b.dylib)

And will @loader_path in the RPATH of a.dylib refer to the directory of a.dylib, and not that of fw?

1 Answers
Related