"make" 如何确定使用哪个链接器?
how does "make" determine which linker to use?
我想升级到 binutils 2.26,所以我按照这里的步骤操作: 解决同样的 "unrecognized relocation" 错误。
现在我的默认链接器是 2.26
$ ld --version
GNU ld (GNU Binutils for Ubuntu) 2.26.1
Copyright (C) 2015 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
但是 "make" 仍然使用“/usr/bin/x86_64-linux-gnu-ld”(即 2.24)并且仍然给出相同的错误。
那么如何强制"make"使用默认链接器?
这取决于您的 Makefile
(您可以使用 remake
-x
进行调试)。请注意 make
有很多内置规则。使用 make -p
也可以打印它们。请注意提及 LINK.c
或 LINK.cc
等的规则,并注意 LD
的使用不多。还要注意 ld
几乎从不直接使用(大多数时候,gcc
或 g++
等其他程序运行它)。
而且也是PATH
variable的事情。所以尝试设置它,让你的新 ld
出现在旧的之前。
通常,您 link 使用 gcc
或 g++
程序(所以它是 GCC which matters, not make
; read about Invoking GCC and its -fuse-ld=
), and that gcc
or g++
will run the linker (you might, but I don't recommend to, change its spec file which governs what actual programs are run by gcc
or g++
which are only drivers to other programs such as cc1
, as
, ld
, collect2
etc...). To understand what programs gcc
or g++
is running, pass it the -v
flag。
But "make" still uses the "/usr/bin/x86_64-linux-gnu-ld" (which is 2.24) and still gives the same error.
在我的Debian系统上/usr/bin/x86_64-linux-gnu-ld
(一般是gcc
启动的,不是直接make
启动的)是一个symlink。您可能(但我不建议这样做)只需更改 symlink.
顺便说一句,您使用的是古老的 Ubuntu14。您最好升级整个发行版(例如,在 2018 年底升级到 Ubuntu 18.04.1 LTS) ,因为不仅 ld
,还有许多其他程序在您的系统上确实很旧。
升级您的发行版比升级、编译、安装和配置每个单独的工具花费的时间更少。
我想升级到 binutils 2.26,所以我按照这里的步骤操作:
现在我的默认链接器是 2.26
$ ld --version
GNU ld (GNU Binutils for Ubuntu) 2.26.1
Copyright (C) 2015 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
但是 "make" 仍然使用“/usr/bin/x86_64-linux-gnu-ld”(即 2.24)并且仍然给出相同的错误。
那么如何强制"make"使用默认链接器?
这取决于您的 Makefile
(您可以使用 remake
-x
进行调试)。请注意 make
有很多内置规则。使用 make -p
也可以打印它们。请注意提及 LINK.c
或 LINK.cc
等的规则,并注意 LD
的使用不多。还要注意 ld
几乎从不直接使用(大多数时候,gcc
或 g++
等其他程序运行它)。
而且也是PATH
variable的事情。所以尝试设置它,让你的新 ld
出现在旧的之前。
通常,您 link 使用 gcc
或 g++
程序(所以它是 GCC which matters, not make
; read about Invoking GCC and its -fuse-ld=
), and that gcc
or g++
will run the linker (you might, but I don't recommend to, change its spec file which governs what actual programs are run by gcc
or g++
which are only drivers to other programs such as cc1
, as
, ld
, collect2
etc...). To understand what programs gcc
or g++
is running, pass it the -v
flag。
But "make" still uses the "/usr/bin/x86_64-linux-gnu-ld" (which is 2.24) and still gives the same error.
在我的Debian系统上/usr/bin/x86_64-linux-gnu-ld
(一般是gcc
启动的,不是直接make
启动的)是一个symlink。您可能(但我不建议这样做)只需更改 symlink.
顺便说一句,您使用的是古老的 Ubuntu14。您最好升级整个发行版(例如,在 2018 年底升级到 Ubuntu 18.04.1 LTS) ,因为不仅 ld
,还有许多其他程序在您的系统上确实很旧。
升级您的发行版比升级、编译、安装和配置每个单独的工具花费的时间更少。