强制链接到未使用的共享库 [英] Force to link against unused shared library
问题描述
从gcc 4.5移动到gcc 4.6,现在它不链接在编译时没有使用的库(即如果没有从它们导入符号)。
Moved from gcc 4.5 to gcc 4.6, and now it does not link against libraries that are not used at compile time (i.e. if no symbols are imported from them).
但是,这些库的目的是它们执行静态构造函数,从而使它们在运行时可用于应用程序(注册它们的符号)。
However the purpose of those libraries is that they execute static constructors and thus make themselves available to the app at runtime (register their symbols).
有办法force gcc通过-l链接所有链接库?
Is there a way to force gcc to link with all libraries listed via -l?
推荐答案
看起来你需要 Wl, - no-as-need
完全禁用它。或者, - 不需要-lfoo --as-needed
仅为禁用按需libfoo
。
It looks like you need either -Wl,--no-as-needed
to totally disable it. Or, --no-as-needed -lfoo --as-needed
to disable "as-needed" just for libfoo
.
资料来源: https:/ /lists.ubuntu.com/archives/ubuntu-devel/2010-November/031991.html
编辑:Ah看起来像 Mat 在评论中打败了我: - )
Ah looks like Mat actually beat me to this in the comment :-)
这篇关于强制链接到未使用的共享库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!