Reputation: 53119
I have some problem with libraries on CentOS. I am not sure what's wrong. When I try to make a project, I get this error:
gcc -Wall -Winline -O2 -fPIC -g -D_FILE_OFFSET_BITS=64 -o bzip2 bzip2.o -L. -lbz2
/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
I can - and did - make a symlink that links /usr/lib64/libc.so
to /usr/lib64/libc-2.17.so
which exists, but that just creates another error:
gcc -Wall -Winline -O2 -fPIC -g -D_FILE_OFFSET_BITS=64 -o bzip2 bzip2.o -L. -lbz2
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/crt1.o: In function `_start':
(.text+0x12): undefined reference to `__libc_csu_fini'
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/crt1.o: In function `_start':
(.text+0x19): undefined reference to `__libc_csu_init'
collect2: error: ld returned 1 exit status
Obviously the toolchain is broken. How can I fix it correctly? Making symlinks obviously isn't fixing anything...
I also tried to reinstall whole development toolchain using yum group remove "Development Tools"
then yum group install "Development Tools"
Upvotes: 1
Views: 1152
Reputation: 136208
/usr/lib64/libc.so
is not a symbolic link, it is a linker script.
On Fedora it contains:
/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf64-x86-64)
GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib64/ld-linux-x86-64.so.2 ) )
And, sure enough:
$ nm -C --defined-only /usr/lib64/libc_nonshared.a
elf-init.oS:
0000000000000070 T __libc_csu_fini
0000000000000000 T __libc_csu_init
...
/usr/lib64/libc.so
belongs to glibc
rpm. I suggest reinstalling it.
Upvotes: 2