gpt4 book ai didi

macos - "___emutls_get_address"符号是什么?

转载 作者:行者123 更新时间:2023-12-03 15:46:13 34 4
gpt4 key购买 nike

哦,我是 GCC、MAC 和 Makefile 的新手。今天我打算使用 MAC OS X 和 GCC 4.4.2 构建一个动态库,但是在链接 .o 文件时,编译器会这样提示:

Undefined symbols:
"___emutls_get_address", referenced from:
_malloc in michael.o
_malloc in michael.o
ld: symbol(s) not found

我用谷歌搜索了这个信息,但我不能很好地理解结果,我想知道这个符号是什么意思,为什么很多程序都有这个链接错误。我也想知道这个错误的可能原因是什么,链接命令是:
g++ -Dx86 -D_GNU_SOURCE -D_REENTRANT  -Wall -m32 \
-fno-strict-aliasing -fno-pic -O3 -ggdb \
michael.o malloc_new.o -o libmichael.so \
-lpthread -lm -lstdc++ -shared

最佳答案

此符号是 gcc 为 Mac Os X 进行的 TLS(线程本地存储)模拟的一部分。 gcc bugzilla 中有一些关于此的错误,例如:http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39888

Using thread local storage (e.g. OpenMP ThreadPrivate variables) on Darwin requires manually linking to TLS emutls, via either -lgcc_s.so.1 or -lgcc_eh

See the threads: http://gcc.gnu.org/ml/gcc/2008-12/msg00145.html http://gcc.gnu.org/ml/gcc/2008-12/msg00107.html

From the above threads, this is evidently quite a mess. However, as I was just bit by this I hoped it useful to have a bug tracking the issue.

...

TLS works fine if I manually link to gcc_s.so.1 or gcc_eh as mentioned above.



因此,可能的解决方案之一是添加 -lgcc_s.so.1-lgcc_eh链接步骤的选项。另一个是更新你的gcc,因为这是gcc的错误。

关于macos - "___emutls_get_address"符号是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7885246/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com