最近将以前实验室师兄写的代码重新实现,代码实现之后,编译通过,却无法链接,可执行文件不能生成
报错为:
TLS definition in /lib/libc.so.6 section .tbss mismatches non-TLS reference in [...]
google了一下,发现了一个解决方法:
http://www.opencascade.org/org/forum/thread_9224/
-----------------
What you need to do is this: open the appropriate makefile (i.e. in TKIGES), find the line DEFAULT_INCLUDES, and add -include /usr/include/errno.h to the end.
This applies to gcc-3.3.6, at least.
--------------------
按照这种方法,修改了makefile文件,但还是无法连接。又有人说可以在makefile的CFLAG中加入 -include /usr/include/errno.h ,还是不行。。
突然间有个新的想法,就直接在主程序里面加入头文件
#include <errno.h>
没想到,竟然生成了所需的可执行文件。误打误撞就把问题解决了。。。
后来找了下资料,原来是errno定义出现错误。按以前的开发文档,我们容易把errno写成:
extern int errno;
但在多线程环境中,errno的定义并不是int类型的。从而出现了问题。解决的办法就直接包含<errno.h> ,而不是自己声明一个外部变量。