@loader_path解析为什么路径? [英] What path does @loader_path resolve to?

查看:48
本文介绍了@loader_path解析为什么路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难理解文件中 @loader_path 所引用的绝对路径.

I'm having a hard time understanding the absolute path that a @loader_path within a file refers to.

user@local:~$ otool -L zlib.so 
zlib.so:
    @loader_path/../../libz.1.dylib (compatibility version 1.0.0, current version 1.2.7)
    /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.0.0)

我想知道系统在哪里寻找libz.1.dylib.

I want to know where the system looks to find libz.1.dylib.

从某些 Mac文档:

@ loader_path/该变量将替换为包含mach-o二进制文件的目录路径,该文件包含使用@loader_path的装入命令.因此,在每个二进制文件中,@loader_path解析为不同的路径

@loader_path/ This variable is replaced with the path to the directory containing the mach-o binary which contains the load command using @loader_path. Thus, in every binary, @loader_path resolves to a different path

我猜想这意味着@loader_path只是目标文件的路径( zlib.so ),但这似乎并不正确.

I would have guessed this means that @loader_path is just the path to the object file (zlib.so), but that doesn't seem to be true.

是否有任何命令行实用程序会将@loader_path解析为尝试打开库时使用的实际路径?

Is there any command line utility that will resolve @loader_path to the actual path that is used when attempting to open a library?

推荐答案

您的猜测是正确的:在这种情况下,@loader_path是目录的路径,包含zlib.so.但是使用此库可能会出现问题.你从哪儿得到那个lib的?如果您是自己构建的,请参见此问题以获取一些信息.
@loader_path对框架和插件很有用,但对独立库则无济于事.

Your guess is right: in this case @loader_path is the path to the directory, containing zlib.so. But there probably will be problems with using this lib. Where did you get that lib? If you are building it by yourself, see this question for some info.
The @loader_path is useful for the frameworks and plugins, but not for the standalone libraries.

这篇关于@loader_path解析为什么路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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