I have an app, call it Animal.app
. Inside its Contents/Frameworks
folder is a framework, say Mammal.framework
. And inside the Versions/A/Frameworks
folder of the framework, I have dog.dylib
. The install name of dog.dylib
is @rpath/dog.dylib. For the "Runpath Search Paths"
setting of the framework, I have specified @loader_path/../Frameworks
. (My reasoning for that last setting is that the "loader" of the dylib would be the binary of the framework, at the path Mammal.framework/Versions/A/Mammal
.)
I get an error message at runtime:
Dyld Error Message:
Library not loaded: @rpath/dog.dylib
Referenced from: /Volumes/VOLUME/*/Animal.app/Contents/MacOS/../Frameworks/Mammal.framework/Versions/A/Mammal
Reason: image not found
I've read Apple's "Run-Path Dependent Libraries" documentation, and Mike Ash's blog post on @rpath
, but I still can't see what I'm doing wrong.
rpath and runpath They are both a list of directories to search for. The only difference between rpath and runpath is the order they are searched in. Specifically, their relation to LD_LIBRARY_PATH - rpath is searched in before LD_LIBRARY_PATH while runpath is searched in after.
@rpath stands for Runpath Search Path. In the Xcode, it's set with LD_RUNPATH_SEARCH_PATH setting. In ld command tool it's set with -rpath parameter when linking. So it's a search path for the linker. Runtime Search Path instructs the dynamic linker to search a list of paths in order, to locate the dynamic library.
In computing, rpath designates the run-time search path hard-coded in an executable file or library. Dynamic linking loaders use the rpath to find required libraries. Specifically, it encodes a path to shared libraries into the header of an executable (or another shared library).
executable_path is the parameter through which users can pass the absolute path of the GeckoDriver binary overriding the system path of GeckoDriver binary to be used for Firefox 47.0. 1 and greater.
It turns out that the right runpath search path is @loader_path/Frameworks
. What I was missing is that @loader_path represents, not the full path to the loader, but that path minus its last component. Mike Ash's blog post does say that, but I somehow missed it. Thus, in the case of a framework, @loader_path ends with the A.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With