如何将共享库与 --as-needed 和 automake 链接起来?
如何使用 Automake 将共享库与 --as-needed
链接?当我尝试将标志添加到 LDFLAGS 时,我看到 libtool 被这样调用:
/bin/bash ../../libtool --mode=link ... -Wl,--as-needed ... dependencies
这会导致对 GCC 的调用如下:
gcc -shared ... dependencies ... -Wl,--as-needed ...
但这是错误的顺序。
有没有办法用 Libtool 来做到这一点?
或者是否有一种使用 Automake 但不使用 Libtool 构建共享库的好方法? (过去由于各种其他原因,我对 Libtool 感到沮丧......)
似乎 Debian 人员也遇到了这个问题(错误报告),但我希望能够为我的项目修复此问题,而不是弄乱我的系统(除非我误解了修复)。
How do I link a shared library with --as-needed
using Automake? When I tried adding the flag to LDFLAGS
, I saw libtool
called as so:
/bin/bash ../../libtool --mode=link ... -Wl,--as-needed ... dependencies
Which results in a call to GCC like so:
gcc -shared ... dependencies ... -Wl,--as-needed ...
But that's the wrong order.
Is there a way to do this with Libtool?
Or is there a nice way to build shared libraries using Automake but without Libtool? (I've been frustrated at Libtool for various other reasons in the past...)
It seems the Debian folks ran into this problem too (bug report) but I'd like to be able to fix this for my project rather than messing with my system (unless I misunderstand the fix).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以通过修改项目源中的 ltmain.sh 脚本来修复您的项目。您甚至可以将其添加为自动工具引导的一部分,如下所示:
https://meego.gitorious.org/tracker/tracker/commit/cf2ca3414aeba146dceacc5ecd84765f4c08a06f
You can fix that just for your project by modifying the ltmain.sh script in your project sources. You can even add it as part of autotools bootstrapping, as in:
https://meego.gitorious.org/tracker/tracker/commit/cf2ca3414aeba146dceacc5ecd84765f4c08a06f
您可以在
Makefile.am
中修复它;基本上它与我的问题的答案,除非您需要使用-(no-)as-needed
而不是-(no-)whole-archive
。You can fix it in
Makefile.am
; basically it's the same as the answer to my question here, except you need to use-(no-)as-needed
instead of-(no-)whole-archive
.这确实是一个令人沮丧的问题,尤其是对于软件包维护而言。
Debian 内置了对修补 libtool 的支持并修复 debian 软件包中的此问题
或者,如果您使用的是 CDBS:
Really a frustrating issue, especially for package maintennance.
Debian has built in support to patch libtool and fix this problem in debian packages
Or, if you're using CDBS: