BROKEN: STL and pthreads statically linked

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I really don't know what I could be doing wrong, but on a _stock_ FC4
install, I'm having a segfault in a pthread call, specifically when
statically linked and including iostream (or other STL includes like string)

Here's the code:

#include <pthread.h>
#include <iostream>

int main(int argc, char *argv[])
{
  pthread_mutexattr_t attr;
  pthread_mutexattr_init( &attr );
}

And I compile with:
g++ -g -c example.c
g++ -static -g -o example example.o -lpthread

The resulting program crashes in pthread_mutexattr_init.  If I merely
remove the include of <iostream>, it works fine.  This also works fine
on FC3.

A dynamic linking variation that blows up:
  g++ -g -o example example.o (leave off the -lpthread, yes this links)
I also noticed that there are _2_ libpthread.so files.  One in /usr/lib,
and another in /lib which is the one ldd points to.

Finally, if I remove the <iostream> include, and attempt to dynamically
link, it _finally_ complains about not finding the
pthread_mutexattr_init call.  Was it somehow getting a
pthread_mutexattr_init from the libstdc++ library??

Can anyone else confirm this crash?  Has anyone else seen this problem?
 I've googled everywhere, and even posted to 2 forums without *any*
response.  And, yes, I must statically link in my case.

Thanks for any help,
Lee


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux