This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

BROKEN: pthreads and c++ statically linked


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 when
statically linked and including iostream (or 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 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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]