@rpath for a dynamic library embedded in a framework

喜欢而已 提交于 2020-01-22 14:27:05

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/13022247/rpath-for-a-dynamic-library-embedded-in-a-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!