使用RPATH但不运行路径? [英] use RPATH but not RUNPATH?

查看:282
本文介绍了使用RPATH但不运行路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

本页面 - <一个href=\"http://labs.qt.nokia.com/2011/10/28/rpath-and-runpath/\">http://labs.qt.nokia.com/2011/10/28/rpath-and-runpath/ - 说,大约为了在ld.so库搜索:

This page - http://labs.qt.nokia.com/2011/10/28/rpath-and-runpath/ - says about order for library search in ld.so:

Unless loading object has RUNPATH:
    RPATH of the loading object,
        then the RPATH of its loader (unless it has a RUNPATH), ...,
        until the end of the chain, which is either the executable
        or an object loaded by dlopen
    Unless executable has RUNPATH:
        RPATH of the executable
LD_LIBRARY_PATH
RUNPATH of the loading object
ld.so.cache
default dirs

,然后建议:

当你船的二进制文件,请使用RPATH,而不是运行路径或保证
  它们运行之前LD_LIBRARY_PATH设置。

When you ship binaries, either use RPATH and not RUNPATH or ensure LD_LIBRARY_PATH is set before they are run.

因此​​,使用 RPATH RUNPATH 是不好的,因为 RUNPATH 种-的取消 RPATH 所以间接动态加载不起作用?但是,为什么那么 RPATH 有利于 RUNPATH 的pcated德$ P $?

So, using RPATH with RUNPATH is bad because RUNPATH kind-of cancels RPATH so indirect dynamic loading doesn't work as expected? But why then RPATH got deprecated in favor of RUNPATH?

有人能解释这种情况?

推荐答案

在你船的二进制,这是很好的提供方式为用户适应二进制自己的系统,除其他事项的具体情况,调整库搜索路径。

When you ship a binary, it's good to provide means for the users to accommodate the binary to the specifics of their own system, among other things, adjusting library search paths.

一个用户一般可以调整 LD_LIBRARY_PATH /etc/ld.co.conf ,这两者都与低precedence比 DT_RPATH ,即你不能覆盖的是二进制硬codeD,而如果你使用DT_RUNPATH相反,用户可以覆盖它与LD_LIBRARY_PATH。

A user can generally tweak LD_LIBRARY_PATH and /etc/ld.co.conf, both of which are with lower precedence than DT_RPATH, i.e. you can't override what is hardcoded in the binary, whereas if you use DT_RUNPATH instead, a user can override it with LD_LIBRARY_PATH.

(FWIW,我觉得 ld.so.conf中也应采取precedence超过 DT_RUNPATH ,但,反正至少我们已经有了 LD_LIBRARY_PATH )。

(FWIW, I think ld.so.conf should also take precedence over DT_RUNPATH, but, anyway, at least we've got LD_LIBRARY_PATH).

另外,我强烈建议不同意上述使用 DT_RPATH 。国际海事组织,其最好用幽冥 DT_RPATH 不是 DT_RUNPATH 运来的二进制文件。

Also, I strongly disagree with the suggestion above to use DT_RPATH. IMO, its best to use nether DT_RPATH not DT_RUNPATH in shipped binaries.

除非

您附带的所有可执行文件的依赖库,并希望确保事情JustWork(TM)安装后,在这种情况下使用 DT_RPATH

you ship all your dependent libraries with your executables and wish to ensure that things JustWork(tm) after installation, in this case use DT_RPATH.

这篇关于使用RPATH但不运行路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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