-pthread and shared libraries

Hasso Tepper hasso at estpak.ee
Tue Jul 22 14:31:38 PDT 2008


While trying to find out why multimedia/gnash doesn't build in DragonFly I 
discovered the point why there is probably no problem in NetBSD. Note, 
that I don't say that this is the problem which must be fixed to get 
gnash to build etc, the problem itself is probably elsewhere.

The point is that using -pthread to link a shared library doesn't link it 
against libpthread.so, it just resolves symbols AFAICS. So far I thought 
that -pthread and -lpthread are equal in linking phase.

hasso at pos:~$ gcc -shared -o test.so test.c -pthread
hasso at pos:~$ ldd ./test.so
. /test.so:
        libc.so.6 => /usr/lib/libc.so.6 (0x28070000)
hasso at pos:~$ gcc -shared -o test.so test.c -lpthread
hasso at pos:~$ ldd ./test.so
. /test.so:
        libpthread.so.0 => /usr/lib/libpthread.so.0 (0x2812b000)
        libc.so.6 => /usr/lib/libc.so.6 (0x28070000)
hasso at pos:~$

What's the reason for that? Is it a historic and could be removed now to 
avoid confusion?


-- 
Hasso Tepper





More information about the Kernel mailing list