other/8888: Linking shared libraries with -pthread fails to link to libpthread

Sebastian Wilhelmi wilhelmi@ira.uka.de
Tue Dec 10 06:31:00 GMT 2002


Hi,

> Synopsis: Linking shared libraries with -pthread fails to link to libpthread
> 
> State-Changed-From-To: open->feedback
> State-Changed-By: bangerth
> State-Changed-When: Tue Dec 10 06:13:52 2002
> State-Changed-Why:
>     I fail to see the reasoning behind the report: what is wrong
>     with passing -lpthread to the linker line? The -pthread
>     changes some things when compiling (as far as I understand,
>     for example the initialization of static variables), so
>     has nothing to do with what libraries are linked. You 
>     would want to specify this separately. Why is this bad?
> 
> http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8888

the man page for gcc-3.2 says:

       -pthread
           Adds support for multithreading with the pthreads library.
           This option sets flags for both the preprocessor and linker.

So we consider -pthread in GLib the preferred way to indicate, that a
program or library is multithreaded. We use it both for linking and
compiling programs and libraries. I got the impression, that also gcc
consideres using -pthread superior to using -D_REENTRANT and -lpthread.

Also for non-shared binaries gcc does the right thing now, but not for
shared objects, why is that?

Bye,
Sebastian

P.S.: I have no write access to GNATS, so I could only write this
e-mail, or is there some way to attach that message to the bug report?
-- 
Sebastian Wilhelmi
mailto:wilhelmi@ira.uka.de
http://goethe.ira.uka.de/~wilhelmi




More information about the Gcc-bugs mailing list