Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 4 down vote accepted

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)

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.

share|improve this answer
That was it! Excellent! Thanks so much for the help. I'll link this answer to the stack overflow question too. – wadesworld Apr 23 '11 at 1:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.