【问题标题】:How to configure a non-standard linker for an autotooled build?如何为自动工具构建配置非标准链接器?
【发布时间】:2014-01-25 15:32:36
【问题描述】:

我想配置一个自动工具项目来调用非标准 链接器(gold linker), 使用 Linux Mint 16/Ubuntu 13.10 的库存自动工具

我相信我会通过以下方式实现这一目标:

  • libtoolize-ing 项目
  • 正在运行./configure LD=/path/to/my/linker ... etc.

但是这没有效果。 libtoolize 已成功。后 一个标准的./configure; make 我现在看到libtool 正在做 链接:

/bin/bash ./libtool  --tag=CXX   --mode=link g++  -g -O2    -o helloworld helloworld.o

但是将LD=/path/to/my/linker 传递给configure 没有任何区别。实验上, 我什至跑了:

./configure LD=/does/not/exist

期待引发错误,但我没有。输出包含:

checking if the linker (/does/not/exist -m elf_x86_64) is GNU ld... no
checking whether the g++ linker (/does/not/exist -m elf_x86_64) supports shared libraries... yes

此后,make 继续成功链接,并像以前一样调用 g++

配置非标准链接器的正确方法是什么?

【问题讨论】:

    标签: linker configure autotools libtool


    【解决方案1】:

    但是将 LD=/path/to/my/linker 传递给配置没有区别

    这是因为LD 几乎从不并且几乎不应该用于链接任何用户空间程序。通过使用适当的编译器驱动程序gccg++ 等)来执行正确的链接。

    配置非标准链接器的正确方法是什么?

    如果您有 /some/path/ld 并且希望 gcc 使用该 ld,请将 -B/some/path 标志传递给 gcc。

    然后你可能想要:

    ./configure CC='gcc -B/some/path' CXX='g++ -B/some/path' ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-03-04
      • 1970-01-01
      • 2020-05-30
      • 2023-03-14
      • 2013-06-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多