linker - ld 中 -Bstatic 标志的各种表示

标签 linker binutils

ld 的联机帮助页中(来自 binutils),这部分是关于 -Bstatic 的变体旗帜:

-Bstatic
-dn
-non_shared
-static
Do not link against shared libraries. This is only meaningful on platforms for which shared libraries are supported. The different variants of this option are for compatibility with various systems. You may use this option multiple times on the command line: it affects library searching for -l options which follow it. This option also implies --unresolved-symbols=report-all. This option can be used with -shared. Doing so means that a shared library is being created but that all of the library's external references must be resolved by pulling in entries from static libraries.



我的问题是关于粗体句子:这些变体究竟要兼容哪些系统?我都看过 -Bstatic-static在各种项目中,但到目前为止还没有看到有人使用其余的两个变体。为了获得最大的兼容性(就跨平台而言),最好使用哪一种?

最佳答案

-Bstatic-static选项当前使用,并且不一样:

  • -static意味着:执行完全静态链接(根本不使用共享库)。
  • -Bstatic意思是:对于任何 -lfoo接下来,仅使用库的存档版本。

  • 其他选项:-dn (1993 年添加)和 -non_shared (在 1994 年添加)是为了与过时的操作系统兼容。

    关于linker - ld 中 -Bstatic 标志的各种表示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31340946/

    相关文章:

    c++ - 与 Lua 链接错误?

    c++ - 使用 avr-gcc 编译器/链接器对链接 avrfix 库中函数的 undefined reference

    gcc - ATLAS undefined reference

    linux - 将附加代码合并到可执行文件中 (arm-linux)

    c - libopcodes : get the size of a instruction

    c++ - 动态链接库 - 构建可执行文件时成功,创建另一个 .so 时相同的设置失败

    c++ - 向 Code::Blocks 添加链接器选项

    perl - 如何用IPC::Open2过滤大量数据?

    c++ - 未知 EABI 对象属性 44

    gcc - 如何使用 binutils 链接器处理静态库之间的递归依赖关系?