Subject: Re: Shared library troubles
To: Ken Nakata <kenn@synap.ne.jp>
From: Andy Finnell <andyf@vei.net>
List: port-mac68k
Date: 07/06/1999 07:49:04
Ken Nakata wrote:
> 
> On Mon, 05 Jul 1999 22:24:20 -0400, Andy Finnell <andyf@vei.net> wrote:
> > Ken Nakata wrote:
> > >
> > > Are libpthread.a and libpthread.so.1.60 built from the same source?
> > > lib*.a is used when you compile the offending program whereas
> > > lib*.so.* is loaded by ld.so when you run that program.
> 
> To correct myself, this is incorrect.  When compiling a dynamically
> linked binary, lib*.so.* is used.  lib*.a is used only when you link
> the binary statically.

So, libpthread.so.1.60 should be linked against my program, but
libpthread_pic.a is what should be loaded at runtime?

> > >  Are you sure
> > > you don't still have an old libpthread.a around somewhere cc might
> > > look into for library files?
> >
> > Thanks!  That was my problem, kinda.  You see, there are actually *3*
> > libraries being built.  The first one, lipthread.a, is the *static* link
> > library (what I was linking in).  The second was libpthread_pic.a, which
> > is the shared object library.  And still yet the third was
> > libpthread.so.1.60, which is the one being loaded at runtime.  The first
> > two are created from the same sources, and the third seems to created
> > from libpthread_pic.a using the ld command.  When I was linking I
> > specified the -lpthread option which gave me the static library.  After
> > changing the flag to -lpthread_pic, everything worked fine.
> 
> This sounds like you have libpthread.so.* somewhere ld.so looks.  What
> do you see when you do "ldconfig -r | grep pthread"?  Is it
> /usr/local/pthreads/lib/libpthread.so.1.60?

This is the results I get when running "ldconfig -r | grep pthread":

search directories: /usr/pkg/lib:/usr/local/lib:/usr/local/pthreads/lib:/usr/local/pthreads/lib
23:-lpthread.1.60 => /usr/local/pthreads/lib/libpthread.so.1.60

> When you cc -lpthread, it looks for libpthread.so.x.y (where x and y
> are the highest version numbers it can find) but when you cc
> -lpthread_pic, it looks for libpthread_pic.so.x.y, fails to find it,
> and *statically* links libpthread_pic.a in, instead.
> 
> And you can specify different lib directories for cc and ld.so, by -L
> option for cc, and by /etc/ld.so.conf or by ldconfig for ld.so.

yes, I've already done this.

> That's why it works when you cc -lpthread_pic whereas it doesn't when
> you -lpthread.  I bet you got a different set of libpthread.a and
> libpthread.so.* somewhere other than /usr/local/pthreads/lib in your
> system that ld.so is trying to load at runtime (how about
> /usr/pkg/lib?).  There's no other explanation I can think of.

No, not any other place other than the directory I built the libraries
in.  I've searched the entire drive (its not a big one) using find.  Any
other ideas what could be going wrong?

Thanks,

	-andy