-pthread ldflag doesn't links against any libs

Alex Zbyslaw xfb52 at dial.pipex.com
Thu Nov 8 10:16:37 PST 2007


Gergely CZUCZY wrote:

>Hello,
>
>I've got a wierd issue here and I'd like to ask for some suggestion.
>
>First of all I've noticed that pcsc-lite (libpcsclite.so) is using pthreads
>but isn't linked against any threading libs. I've started digging around
>the source, and it really wasn't linked against it, nor mentioned in the
>pkgconfig .pc file among the Libs: section.
>
>The strange part came after this. I've re-linked the lib by hand, and when
>I specified -pthread as an additional flag at the linking stage it wasn't
>linked against any threading libs, while specifying -lpthread/-lthr worked
>just fine.
>
>The original command was:
># gcc -shared  .libs/libpcsclite_la-debug.o .libs/libpcsclite_la-dyn_hpux.o .libs/libpcsclite_la-dyn_macosx.o .libs/libpcsclite_la-dyn_unix.o .libs/libpcsclite_la-error.o .libs/libpcsclite_la-winscard_clnt.o .libs/libpcsclite_la-strlcat.o .libs/libpcsclite_la-strlcpy.o .libs/libpcsclite_la-sys_unix.o .libs/libpcsclite_la-thread_unix.o .libs/libpcsclite_la-utils.o .libs/libpcsclite_la-winscard_msg.o   -pthread -Wl,-soname -Wl,libpcsclite.so.1 -o .libs/libpcsclite.so.1
>  
>
Note that this already has -pthread

>Which resulted in:
># ldd .libs/libpcsclite.so.1
>.libs/libpcsclite.so.1:
>#
>
>After this I've added -pthread:
># gcc -shared  .libs/libpcsclite_la-debug.o .libs/libpcsclite_la-dyn_hpux.o .libs/libpcsclite_la-dyn_macosx.o .libs/libpcsclite_la-dyn_unix.o .libs/libpcsclite_la-error.o .libs/libpcsclite_la-winscard_clnt.o .libs/libpcsclite_la-strlcat.o .libs/libpcsclite_la-strlcpy.o .libs/libpcsclite_la-sys_unix.o .libs/libpcsclite_la-thread_unix.o .libs/libpcsclite_la-utils.o .libs/libpcsclite_la-winscard_msg.o   -pthread -Wl,-soname -Wl,libpcsclite.so.1 -pthread -o .libs/libpcsclite.so.1 && ldd .libs/libpcsclite.so.1
>.libs/libpcsclite.so.1:
>  
>
And this just added -pthread a 2nd time, so no surprise results were the 
same :-)

 From looking at the manual page here 
http://www.freebsd.org/cgi/man.cgi?query=gcc&apropos=0&sektion=0&manpath=FreeBSD+6.2-stable&format=html
the -pthread option only ever appears in various *machine specific* 
sections (RS6000, IA64) so in one sense it's no surprise that it didn't 
do what you wanted, because it wasn't meant to.

Under 5.4 -pthread maybe did somewhat like what you expected (linked to 
libc_r instead of libc) but I'm guessing that with the addition of extra 
thread libraries under 6.X that you were meant to specify which one you 
actually wanted to the linker.  (The man page on 5.4 lists -pthread as a 
specific FreeBSD option to do this very specific action).

Not an expert, but that's how I interpet the information.

--Alex



More information about the freebsd-ports mailing list