MacOSX:哪些动态库通过二进制链接? [英] MacOSX: which dynamic libraries linked by binary?

查看:146
本文介绍了MacOSX:哪些动态库通过二进制链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法弄清楚为什么我的二进制文件无法加载.它是MATLAB加载的dylib(MEX文件),并链接到位于不同位置的许多dylib. MATLAB告诉我它无法加载MEX文件,但是我无法弄清它找不到哪个依赖项.

I have not been able to figure out why my binary is not loading. It is a dylib loaded by MATLAB (MEX-file), and links to quite a few dylibs in different locations. MATLAB tells me it cannot load the MEX-file, but I cannot figure out which of its dependencies it cannot find.

有人对如何调试这样的东西有任何建议吗?

Does anybody have any suggestions for how to debug something like this?

在Linux上,ldd是调试此问题的理想工具.人们一直说otool -L是与Linux ldd等效的MacOS,但这不是事实. ldd实际上是在查找库,并告诉您可以找到哪些库以及在何处找到它们. otool -L仅告诉您需要链接的库.无需检查它们是否在那里.它甚至没有告诉您使用@rpath时在哪里搜索库.

On Linux, ldd is the perfect tool to debug this problem. People keep saying that otool -L is the MacOS equivalent to the Linux ldd, but this is not true. ldd actually looks for the libraries, and tells you which ones can be found, and where they were found. otool -L only tells you what libraries are needed to link against. It does not effort to check to see if they are there. It doesn't even tell you where libraries are searched for when they use @rpath.

otool -l(小写L)为您提供了加载命令"的转储,您可以在其中看到LC_RPATH命令,这些命令确定了在何处搜索@rpath库.但是这些无法向我解释找不到哪个依赖项.

otool -l (lowercase L) gives you a dump of the "load commands", there you can see the LC_RPATH commands, which establish where @rpath libraries are searched for. But these have not been able to explain to me which dependency is not found.

推荐答案

在运行matlab之前尝试设置以下环境变量:

Try setting these environment variables before running matlab:

export DYLD_PRINT_LIBRARIES=1
export DYLD_PRINT_LIBRARIES_POST_LAUNCH=1
export DYLD_PRINT_RPATHS=1

运行man dyld获得更多可能性.

您还可以像这样仅为matlab命令设置变量:

You can also set the variables for just the matlab command like this:

DYLD_PRINT_LIBRARIES=1 DYLD_PRINT_LIBRARIES_POST_LAUNCH=1 DYLD_PRINT_RPATHS=1 matlab

这篇关于MacOSX:哪些动态库通过二进制链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆