dlopen() 错误图像未找到
我有首先加载 .dylib 的软件,让我们使用以下命令调用 libFirst.dylib:
void* handle = dlopen(path.c_str(), RTLD_LAZY | RTLD_GLOBAL);
稍后在加载的 libFirst.dylib 的函数内,我尝试使用相同的命令加载另一个 .dylib,但对于 libSecond.dylib,加载这个共享库在我的 Xcode 控制台中给了我以下警告:
error warning: Ignored unknown object module at 0x129310 with type 0x8a8399
dlerror: dlopen(/path/libSecond.dylib, 9): Library not loaded: libFirst.dylib
Referenced from: /path/libSecond.dylib
Reason: image not found
我没有得到的是它说 libFirst.dylib 未加载,但我当前位于 libFirst.dylib 的函数内,所以这是怎么回事?
我在 DYLD_LIBRARY_PATH 中的所有路径看起来也都是正确的。
预先感谢,我已经被困在这个问题上好几天了。
I have software that first loads a .dylib lets call libFirst.dylib using the following command:
void* handle = dlopen(path.c_str(), RTLD_LAZY | RTLD_GLOBAL);
Later on inside a function from the loaded libFirst.dylib I attempt to load another .dylib using the same command but for libSecond.dylib, the loading of this shared library gives me the following warnings in my Xcode console:
error warning: Ignored unknown object module at 0x129310 with type 0x8a8399
dlerror: dlopen(/path/libSecond.dylib, 9): Library not loaded: libFirst.dylib
Referenced from: /path/libSecond.dylib
Reason: image not found
What I don't get is that its says libFirst.dylib is not loaded but I am currently inside a function from libFirst.dylib, so how can this be?
All my paths in DYLD_LIBRARY_PATH appear correct too.
Thanks in advance, I have been stuck on this for days.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我最终使用 -install_name 将所有库的安装名称更改为 @rpath/dylibName.dylib,然后在 Xcode 中使用 @loader_path 设置运行路径搜索路径以查找我正在使用的所有 .dylib。
I ended up using -install_name to change the install name of all my libraries to @rpath/dylibName.dylib and then in Xcode I set the Runpath Search paths using @loader_path to find all my .dylibs that I was using.
使用:
然后用以下命令检查:
use:
then check it with:
我认为解决此错误的一个更简单的方法是恢复到没有收到此错误的早期版本。右键单击项目文件夹并导航到本地历史记录以恢复到早期版本。我验证了它可以在 Mac OS Big sur 上安装的 android studio 上运行。
I think an easier way to get around this error would be to revert to an earlier version where you were not getting this error. Right click on the project folder and navigate to local history to revert to an earlier version. I verified this to be working on the android studio installed on Mac OS Big sur.