在 StackOverflow 上询问,但建议的解决方案涉及使用 gcc 3.4。
问题详细信息:
StackOverflow 上的 _dl_stack_flags_error 问题
但是,我的 Ubuntu 10:
wade@wadesworld:~$ uname -a
Linux wadesworld 2.6.18-194.8.1.el5.028stab070.5ent #1 SMP Fri Sep 17 19:46:02 MSD 2010 i686 GNU/Linux
Run Code Online (Sandbox Code Playgroud)
至少只允许 gcc 4.1。
有没有人看到/解决了这个问题?
查看您的 Stack Overflow 问题中的信息,我认为问题是由于您静态链接libpthread. 我整理了以下琐碎的测试程序:
#include <pthread.h>
static void *
thread_start(void *arg)
{
}
int
main(int argc, char **argv)
{
pthread_t thread_id = 0;
void *result = NULL;
pthread_create(&thread_id, NULL, &thread_start, NULL);
pthread_join(thread_id, &result);
}
Run Code Online (Sandbox Code Playgroud)
如果我用 编译它gcc -o test test.c -lpthread,我不会出错。如果我尝试静态链接线程但动态链接其他所有内容,则会收到许多错误,包括丢失的_dl_stack_flags错误:
$ gcc -o test test.c -Wl,-Bstatic -lpthread -Wl,-Bdynamic
/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../../libpthread.a(pthread_create.o): In function `allocate_stack':
/build/buildd/eglibc-2.13/nptl/allocatestack.c:451: undefined reference to `_dl_stack_flags'
/build/buildd/eglibc-2.13/nptl/allocatestack.c:595: undefined reference to `_dl_stack_flags'
/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../../libpthread.a(ptw-pause.o): In function `__pause_nocancel':
/build/buildd/eglibc-2.13/nptl/../sysdeps/unix/syscall-template.S:82: undefined reference to `__syscall_error'
/build/buildd/eglibc-2.13/nptl/../sysdeps/unix/syscall-template.S:82: undefined reference to `__syscall_error'
/usr/lib/x86_64-linux-gnu/gcc/x86_64-linux-gnu/4.5.2/../../../libpthread.a(nptl-init.o): In function `__pthread_initialize_minimal_internal':
/build/buildd/eglibc-2.13/nptl/nptl-init.c:277: undefined reference to `__libc_setup_tls'
/build/buildd/eglibc-2.13/nptl/nptl-init.c:295: undefined reference to `_dl_cpuclock_offset'
/build/buildd/eglibc-2.13/nptl/nptl-init.c:437: undefined reference to `_dl_init_static_tls'
/build/buildd/eglibc-2.13/nptl/nptl-init.c:439: undefined reference to `_dl_wait_lookup_done'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)
您没有列出那些额外的错误,但我认为它们也会出现在您身上。我怀疑只有当您尝试静态链接libpthread但动态链接时才会发生此错误libc。如果您动态链接这两项工作,我怀疑如果您静态链接两者,我怀疑这也会工作。这并不奇怪,因为这两个库相当密切相关。
所以我建议调整你的构建配置以动态链接libpthread.
| 归档时间: |
|
| 查看次数: |
8558 次 |
| 最近记录: |