问题描述
长话短说:我从事的工作是相对rpath链接与此脚本(即使用自动制作,自动配置,libtool).问题是二进制可执行文件或so
文件中的最后rpath
/runpath
条目仍然具有绝对路径:
Long story short: I worked on relative rpath linking with this script (that uses automake, autoconf, libtool).The problem is that the final rpath
/runpath
entry in the binary executable or so
file still has the absolute path:
- 事实证明,默认情况下,libtool的配置如下: hardcode_libdir_flag_spec 包含任何
-L
值(如果在LDFLAGS
中进行了设置)
- it turned out libtool is configured by default like this with hardcode_libdir_flag_spec to include any
-L
value if it's set inLDFLAGS
唯一的问题仍然是:如何以及在什么时候(正确的方式)设置其他libtool变量,例如hardcode_minus_L
. (我已经在网上搜索了,但是找不到任何东西.)
The only question remains: how and at which point (what's the proper way) can I set other libtool variables, like hardcode_minus_L
. (I've searched for it on the net, but I couldn't find anything.)
我尝试执行以下操作:
- 在配置之后,用
libtool
文件(在正确的目录中)的sed
替换变量的值:可以工作,但是在调用make
时,它将再次覆盖整个libtool
文件(已重新生成)
- after configure is called I tried to replace the value of the variable with
sed
inlibtool
file (in the proper directory): it worked but whenmake
is called it overwrote the wholelibtool
file again (it was regenerated)
请注意,这会影响2个二进制文件,即rpath
/runpath
和objdump -p
的条目:
Note, that 2 binary files are effected by this, entry for rpath
/runpath
with objdump -p
:
- libcurl.so :
RUNPATH /home/user1/lib/rtorrent-0.9.7-1.5.3/lib:$ORIGIN/../lib
- rtorrent :
RUNPATH $ORIGIN/../lib:/home/user1/lib/rtorrent-0.9.7-1.5.3/lib
- libcurl.so :
RUNPATH /home/user1/lib/rtorrent-0.9.7-1.5.3/lib:$ORIGIN/../lib
- rtorrent :
RUNPATH $ORIGIN/../lib:/home/user1/lib/rtorrent-0.9.7-1.5.3/lib
谢谢
推荐答案
事实证明,在configure.ac
中修改这些变量非常容易,不需要sed
-在摆弄并查看生成的脚本之后.唯一令人困惑的是,这些变量可以应用于 tags
在给定的项目中定义.
It turned out it's fairly easy to modify these variables in configure.ac
, no need for sed
- after fiddling around and taking a look into the generated scripts. The only thing can be confusing that these variables can be applied to tags
defined in the given project.
例如要将hardcode_libdir_flag_spec
更改为rtorrent
项目中的空值(意味着它将破坏编译),您将插入configure.ac
:
E.g. to change hardcode_libdir_flag_spec
to an empty value in rtorrent
project (means it will break compilation), you would insert into configure.ac
:
_LT_TAGVAR(hardcode_libdir_flag_spec, )=""
_LT_TAGVAR(hardcode_libdir_flag_spec, CXX)=""
_LT_TAGVAR(hardcode_minus_L, )=yes
_LT_TAGVAR(hardcode_minus_L, CXX)=yes
第二个参数是tag
或default
标记(如果为空).
The 2nd parameter is the tag
or default
tag if it's empty.
这篇关于如何,何时,在哪里设置libtool的脚本变量? (例如hardcode_minus_L)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!