6

Asked on StackOverflow, but the suggested solution involves using gcc 3.4.

Question with full details:

_dl_stack_flags_error question on StackOverflow

However, my 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

only allows gcc 4.1 as a minimum.

Has anyone seen / solved this problem?

0

1 Answer 1

6

Looking at the information in your Stack Overflow question, I believe that the problem is due to you statically linking libpthread. I put together the following trivial test program:

#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);
}

If I compile it with gcc -o test test.c -lpthread, I get no errors. If I attempt to link thread statically but everything else dynamically, I get a number of errors including the missing _dl_stack_flags error:

$ 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

You didn't list those additional errors, but I assume they showed up for you too. I suspect that this error only occurs if you try to statically link libpthread but dynamically link libc. If you dynamically link both things work, and I suspect that if you statically link both I suspect that would work too. This isn't that surprising, since the two libraries are fairly closely related.

So I'd suggest adjusting your build configuration to dynamically link libpthread.

4
  • That was it! Excellent! Thanks so much for the help. I'll link this answer to the stack overflow question too.
    – wadesworld
    Apr 23, 2011 at 1:30
  • That's not the case for me. I get pretty the same errors whenever I statically link everything.
    – Paolo M
    Jul 27, 2016 at 7:18
  • libc is libgcc ?
    – CS QGB
    Dec 18, 2022 at 13:28
  • @CSQGB: no. I mean glibc (i.e. the C standard library). The two libraries are closely tied, so you generally want to either have libc and libpthread both static or both dynamic. Dec 20, 2022 at 6:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .