'Why does ld need /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 while its default dynamic linker is /lib64/ld-linux-x86-64.so.2?
In x86-64 target Debian, most of the programs are link against shared objects with the /lib64/ld-linux-x86-64.so.2
. And there is also one in /lib/x86_64-linux-gnu/
, so I delete it as I thought
it is unnecessary :
rm /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
then test :
gcc test.c
it showed as the following :
/usr/bin/ld: cannot find /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 inside /
collect2: error: ld returned 1 exit status
So , why does ld
need to find the /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
while the default dynamic linker is /lib64/ld-linux-x86-64.so.2
when linking ?
Solution 1:[1]
/lib64/ is a symlink to /usr/lib64/.
cd /lib64/ && ls -l ld-linux-x86-64.so.2
lrwxrwxrwx 1 root .. ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-2.28.so
cd /usr/lib/x86_64-linux-gnu/
ls -l ld-linux-x86-64.so.2
lrwxrwxrwx 1 root .. ld-linux-x86-64.so.2 -> ld-2.28.so
The main link to the linker ld-2.28.so is /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
: Do not change it. (The link in /lib64/ and /usr/lib64/ is for compatibility reasons with certain software.)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |