gcc 4.5中关于链接引入的更改? [英] Changes introduced in gcc 4.5 with respect to linking?

查看:128
本文介绍了gcc 4.5中关于链接引入的更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我使用gcc 4.4编译并链接它时,一切正常:


  1. 没有编译时警告或错误,
  2. 没有链接时间警告或错误,
  3. / li>
  4. ldd libmyproject.so 正确地报告与其他共享库的依赖关系。

当我使用gcc 4.5进行编译和链接(另一方面,使用完全相同的标记)时,我遇到以下症状:


  • 没有编译时警告或错误,
  • 没有链接时间警告或错误

  • 库与其他共享库没有正确链接:当我运行 ldd 时没有看到连接,并且当我尝试使用它:虽然它与gcc 4.4一起工作,但它在运行时崩溃与GCC 4.5与符号未找到错误(当然从其他lib)。

  • 我看了发布说明,我的直觉是它与新的链接时间优化有关,但我无法理解它们的详细信息。



    有没有人遇到类似的情况和/或有任何建议要提供?



    (注意4.6的结果在外观上与4.5 )。

    解决方案

    总结Mat的回答来自 GCC 4.5 vs 4.4与依赖链接和讨论中的评论,你需要链接:

       -  copy-dt-needed-entries和--no-as-needed 


    I have a project that produces a shared library which is linked against another, also shared, library.

    When I compile and link it with gcc 4.4, everything works:

    1. no compile-time warning or error,
    2. no linking time warning or error and
    3. ldd libmyproject.so correctly reports the dependency with the other shared library.

    When I compile and link it with gcc 4.5, on the other hand (with the exact same flags), I have the following symptoms:

    1. no compile-time warning or error,
    2. no linking time warning or error but
    3. the library is not correctly linked against the other shared lib: this manifest itself when I run ldd and don't see the connection, and also when I try to use it: while it works with gcc 4.4, it crashes at run-time with gcc 4.5 with a "symbol not found" error (of course from the other lib).

    I looked at the release notes and my intuition is that it has something to do with the new link-time optimization, but I could not understand them in enough details.

    Did anyone encounter a similar situation and/or has any advice to offer?

    (Note that results with 4.6 are in appearance identical to 4.5).

    解决方案

    To summarize Mat's answer from GCC 4.5 vs 4.4 linking with dependencies and the discussion in the comments, you need to link with:

    --copy-dt-needed-entries and --no-as-needed
    

    这篇关于gcc 4.5中关于链接引入的更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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