This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problems with shared library linking and pthreads


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]