/bin/ld: this linker was not configured to use sysroots

problem

Encountered a problem when compiling the program:

/bin/ld: this linker was not configured to use sysroots
collect2: error: ld returned 1 exit status

solve

  • upgradebinutils

analysis

After checking, this article mentions that the reason for the problem is that there are no configuration parameters when compiling and installingldsysroot .

Then the possible solution is to reinstall the ldlinker.

Check out ldthe version. The method used here is to find ldpackages that can be provided :

[root: ~]# yum whatprovides ld
Loaded plugins: fastestmirror
Repository epel is listed more than once in the configuration
Repository epel-debuginfo is listed more than once in the configuration
Repository epel-source is listed more than once in the configuration
base                                                                                                                    | 3.6 kB  00:00:00
epel                                                                                                                    | 4.7 kB  00:00:00
extras                                                                                                                  | 2.9 kB  00:00:00
updates                                                                                                                 | 2.9 kB  00:00:00
Loading mirror speeds from cached hostfile
binutils-2.27-43.base.el7.x86_64 : A GNU collection of binary utilities
Repo        : base
Matched from:
Filename    : /usr/bin/ld



binutils-2.27-43.base.el7_8.1.x86_64 : A GNU collection of binary utilities
Repo        : updates
Matched from:
Filename    : /usr/bin/ld



binutils-2.25.1-22.base.el7.x86_64 : A GNU collection of binary utilities
Repo        : installed
Matched from:
Filename    : /bin/ld



binutils-2.25.1-22.base.el7.x86_64 : A GNU collection of binary utilities
Repo        : installed
Matched from:
Filename    : /usr/bin/ld



Query results suggest that the current ldlinker version 2.25.1-22, not the latest version 2.27-43 .

Inspired by this, updatebinutils :

[root: ~]# yum upgrade binutils
Loaded plugins: fastestmirror
Repository epel is listed more than once in the configuration
Repository epel-debuginfo is listed more than once in the configuration
Repository epel-source is listed more than once in the configuration
base                                                                                                                    | 3.6 kB  00:00:00
epel                                                                                                                    | 4.7 kB  00:00:00
extras                                                                                                                  | 2.9 kB  00:00:00
updates                                                                                                                 | 2.9 kB  00:00:00
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package binutils.x86_64 0:2.25.1-22.base.el7 will be updated
---> Package binutils.x86_64 0:2.27-43.base.el7_8.1 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===============================================================================================================================================
 Package                        Arch                         Version                                       Repository                     Size
===============================================================================================================================================
Updating:
 binutils                       x86_64                       2.27-43.base.el7_8.1                          updates                       5.9 M

Transaction Summary
===============================================================================================================================================
Upgrade  1 Package

Total download size: 5.9 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
binutils-2.27-43.base.el7_8.1.x86_64.rpm                                                                                | 5.9 MB  00:00:00
BDB2053 Freeing read locks for locker 0xcd: 17326/140635147335424
BDB2053 Freeing read locks for locker 0xce: 17326/140635147335424
BDB2053 Freeing read locks for locker 0xcf: 17326/140635147335424
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : binutils-2.27-43.base.el7_8.1.x86_64                                                                                        1/2
  Cleanup    : binutils-2.25.1-22.base.el7.x86_64                                                                                          2/2
  Verifying  : binutils-2.27-43.base.el7_8.1.x86_64                                                                                        1/2
binutils-2.25.1-22.base.el7.x86_64 was supposed to be removed but is not!
  Verifying  : binutils-2.25.1-22.base.el7.x86_64                                                                                          2/2

Updated:
  binutils.x86_64 0:2.27-43.base.el7_8.1

Failed:
  binutils.x86_64 0:2.25.1-22.base.el7

Complete!

After the update is complete, recompile your own program, and the problem is solved at this time .

Guess you like

Origin blog.csdn.net/qq_29695701/article/details/108760466