最近在学习关于文件操作的过程中,编译程序时遇到了错误提示:
/usr/bin/ld: errno: TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference in /tmp/ccKZsHdg.o
/lib/libc.so.6: could not read symbols: Bad value
collect2: ld returned 1 exit status
当时在网上查了好长时间,不少人也遇到这些问题。将
extern int errno;替换为
#include <errno.h>便可解决问题,出于线程安全的原因,新的Linux版本将全局变量改成了局部变量。最直观的解决办法就是在程序开头加上
#include <errno.h>,将extern int errno这一句省略。