参考:
【CodeTyphon】GCC编译出现 undefined reference to __libc_csu_init' 和
__libc_csu_fini’的解决方法 - 峋山隐修会 - 博客园
https://www.cnblogs.com/caibirdy1985/p/13220963.html
LInux下编译发生的libc相关错误 - gqtc - 博客园
https://www.cnblogs.com/gqtcgq/p/7247158.html
完整报错信息:
configure:3118: gcc conftest.c >&5
/lib/../lib64/crt1.o: In function `_start':
(.text+0x12): undefined reference to `__libc_csu_fini'
/lib/../lib64/crt1.o: In function `_start':
(.text+0x19): undefined reference to `__libc_csu_init'
collect2: error: ld returned 1 exit status
基本确认是glibc(GNU C 库)的问题。首先确认glibc的版本:
ldd --version
然后查找位置:
whereis libc
或者
ldconfig -p | grep libc.so
我的办法也是去另一个相同版本glibc的地方拷贝一份libc.so,替换即可。
这个文件也是个文本文档,直接拷贝过去就解决了。
/* 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 ) )
另外我的gcc版本是5.3,glibc的版本是2.17。