2017-07-24 34 views
0

长话短说:我曾在relative rpath linkingthis script(即uses的automake,autoconf的,libtool的)。 的问题是,在二进制可执行文件或so文件最终rpath/runpath条目仍具有绝对路径:如何,何时,在哪里设置的libtool脚本变量? (例如hardcode_minus_L)

  • 原来的libtool默认情况下,像这样与hardcode_libdir_flag_spec配置为包括任何-L值,如果它被设置在LDFLAGS

唯一的问题是:如何以及在该点(什么是适当的方式),我可以设置其他libtool的变量,如hardcode_minus_L。 (我搜索了它在网络上,但我无法找到任何东西。)

我试着做到以下几点:

  • 被调用后configure我试图替换变量的值与sedlibtool文件(在正确的目录):它的工作,但是当make把它叫做再次改写整个libtool文件(这是再生)

注意,这2个二进制文件是由这个影响,对于入门rpath/runpathobjdump -p

  • libcurl.soRUNPATH /home/user1/lib/rtorrent-0.9.7-1.5.3/lib:$ORIGIN/../lib
  • rtorrentRUNPATH $ORIGIN/../lib:/home/user1/lib/rtorrent-0.9.7-1.5.3/lib

感谢

回答

0

原来,它很容易在configure.ac修改这些变量,无需sed - 摆弄周围和服用后一看到生成的脚本中。唯一可能引起混淆的是,这些变量可以应用于给定项目中定义的 tags

E.g.在rtorrent项目(意味着它将打破编译)改变hardcode_libdir_flag_spec为空值,你会插入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 

的第二个参数是tagdefault标签,如果它是空的。

+0

请注意,我无法解决原来的问题,无论我尝试使用它们:)因此,我只是坚持使用'chrpath' util来更改二进制文件中生成的'rpath'条目。 – Krisztian

1

我不知道是否修改生成的libtool脚本是解决问题的最佳办法。但是如果你这样做,你需要通过在AC_CONFIG_COMMANDS内执行sed命令来使方法健全。

libtool脚本在config.status期间生成为配置命令(AC_CONFIG_COMMANDShttps://www.gnu.org/software/autoconf/manual/autoconf.html#Configuration-Commands)。

config.status: executing libtool commands 

您可以通过添加另一个AC_CONFIG_COMMANDS来修改此生成的文件。 我们使用以下改变prefer_static_libs变量:

AC_CONFIG_COMMANDS([libtool-fix-linker-preference],                              
    [${SED} -e '1,/prefer_static_libs=/ s/prefer_static_libs=.*$/prefer_static_libs=yes/' \ 
    libtool > libtool.fix && mv libtool.fix libtool]) 

你需要你的AC_CONFIG_COMMANDSLT_INIT触发。 configure/config。状态报告执行:

config.status: executing libtool commands 
config.status: executing libtool-fix-linker-preference commands 

希望帮助,

基督教

+0

感谢您的回答。不幸的是,这不适用于rtorrent:它首先触发[autogen.sh](https://github.com/rakshasa/rtorrent/blob/226e670decf92e7adaa845a6982aca4f164ea740/autogen.sh),它不会触发自定义的AC_CONFIG_COMMANDS在[configure.ac](https://github.com/rakshasa/rtorrent/blob/226e670decf92e7adaa845a6982aca4f164ea740/configure.ac)开头:在配置输出结束时只有以下行可见:'config.status:execution libtool命令' – Krisztian

+0

感谢您的回答,再次,它告诉我,我正朝着正确的方向前进(所以我向你致敬)。 – Krisztian

相关问题