Dynamically linking to pthread library

Dustin Lang dalang at cs.ubc.ca
Wed Apr 5 23:20:51 EST 2006


Hi,

> Do you need to explicitly specify -pthread option to g++ to make the 
> target library link with pthread dynamically. Otherwise does it 
> statically link to pthread library on ppc64 power5.

You can use "ldd" to tell you which libraries are dynamically linked to an 
executable.  Read "man ldd" for more details.  You can add the "-v" 
(verbose) flag to your g++ link command, which will tell you the full 
details of what it's linking in.

My guess is that you need to specify "-pthread" explicitly.  What happens 
if you create a program that calls a pthread function and you don't 
specify "-pthread".  Does it link?  If it does, then the compiler is 
getting that pthread definition from _somewhere_.  What does "g++ -v" tell 
you?  What does "ldd" tell you?

By the way, a better way to ask questions on a mailing list is to explain 
what you're trying to do, what you've tried to do to achieve it, and why 
it didn't work.  It usually helps to be explicit about each step.  Show 
that you've tried to figure it out for yourself.

Cheers,
dstn.




More information about the Linuxppc-dev mailing list