This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Problems with shared library linking and pthreads
- From: Johannes Stezenbach <js at convergence dot de>
- To: Erland Lewin <erl at voxi dot com>, binutils at sources dot redhat dot com,bug-glibc at sources dot redhat dot com
- Date: Thu, 8 Aug 2002 16:26:04 +0200
- Subject: Re: Problems with shared library linking and pthreads
- References: <3D526EAD.5040402@voxi.com> <20020808132757.GA2602@nevyn.them.org>
On Thu, Aug 08, 2002 at 09:27:57AM -0400, Daniel Jacobowitz wrote:
> On Thu, Aug 08, 2002 at 03:14:21PM +0200, Erland Lewin wrote:
> > cc -g -c -o testlib.o testlib.c
> > ld -shared testlib.o -lpthread -o libtestlib.so
> > cc -g -c -o testapp.o testapp.c
> > cc -L. testapp.o -ltestlib -lpthread -o testapp
>
> and often libgcc_s. The rule is, don't ever use "ld" to link a shared
> library. You should only be doing that for custom static binaries, if
> ever. Use "cc -shared testlib.o -lpthread -o libtestlib.so" (and maybe
> -Wl,-soname,libtestlib.so") and see if that helps.
And don't forget to add -D_REENTRANT (or -pthread) when compiling when
you intend to link with -lpthread.
With gcc you can use -v to see what's going on behind the scenes.
Regards,
Johannes