Subject: Re: Shared library troubles
To: Ken Nakata <kenn@synap.ne.jp>
From: Andy Finnell <andyf@vei.net>
List: port-mac68k
Date: 07/05/1999 22:24:20
Ken Nakata wrote:
> 
> On Mon, 05 Jul 1999 18:48:04 -0400, Andy Finnell <andyf@vei.net> wrote:
> > I'm having a hard time getting the pthread shared library to work
> > correctly.  Everything works fine in the compile & link phase, but when
> > I run the program, I run into trouble.
> >
> > Here's what ld.so gives me:
> >
> > /usr/libexec/ld.so: symbol ___sF at 0x403d1ec in
> > /usr/local/pthreads/lib/libpthread.so.1.60 changed size: expected 264,
> > actual 192
> >
> > After this the program segfaults.  At first I thought it was my code, so
> > I moved the function it was segfaulting in, into the function that calls
> > it.  The above error still shows up.  If I statically link the program
> > everything goes fine.
> >
> > Any ideas of why ld.so is giving me the above warning/error?  What
> > should I be looking for?  Thanks,
> 
> 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.  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 is a bit odd because the other pthread libraries I've worked with
(LinuxThreads and IRIX pthreads) both allow the -lpthread option to work
with shared libraries.  hmmm... but IRIX doesn't use shared libraries...
maybe I was just imagining things.  Does anybody who's used MIT-pthreads
on another NetBSD platform know if this is the expected behaviour (using
-lpthread for static and -lpthread_pic for shared)?  If its not, I have
some more work to do...

Thanks,

	-andy