Subject: Re: ld.so finds library, loses library
To: None <netbsd-help@NetBSD.org>
From: James K. Lowden <jklowden@schemamania.org>
List: netbsd-help
Date: 05/16/2007 17:35:24
Patrick Welche wrote:
> On Wed, May 16, 2007 at 05:06:49PM -0400, James K. Lowden wrote:
> > I have an executable for which the runtime linker fails to find a
> > shared object that ldd admits is there.  I'm hoping someone here can
> > point me in the right direction.  I include the output of ldd,
> > readelf, and the link command line below.  
> > 
> > 	$ uname -rs
> > 	NetBSD 2.0_BETA
> > 	$ .libs/bsqlodbc
> > 	Shared object "libodbcinst.so.1" not found
> > 
> > $ ldd  .libs/bsqlodbc
> > .libs/bsqlodbc:
> >          -lodbcinst.1 => not found
> >          -lc.12 => /usr/lib/libc.so.12
> >          -ltdsodbc.0 => /usr/pkg/lib/libtdsodbc.so.0
> >          -lpthread.0 => /usr/lib/libpthread.so.0
> >          -lodbcinst.1 => /usr/local/lib/libodbcinst.so.1
> >          -lodbc.1 => /usr/local/lib/libodbc.so.1
> 
> How about ldd for libtdsodbc.so.0?
> 
> For me:
> 
> libtdsodbc.so.0.0:
>         -lpthread.0 => /usr/lib/libpthread.so.0
>         -lodbcinst.1 => /usr/local/lib/libodbcinst.so.1
>         -lcrypt.0 => /lib/libcrypt.so.0
>         -lcrypto.3 => /usr/lib/libcrypto.so.3
>         -lssl.4 => /usr/lib/libssl.so.4
> 
> so it could be that one which doesn't have an rpath = /usr/local/lib

I thought I'd solved it, but I hadn't gone far enough, and you're right:
When the ODBC library starts cranking, it can't find what it wants:

$ ldd /usr/pkg/lib/libtdsodbc.so.0
/usr/pkg/lib/libtdsodbc.so.0:
         -lodbcinst.1 => not found
         -lc.12 => /usr/lib/libc.so.12
$ readelf -d /usr/pkg/lib/libtdsodbc.so.0 | sed /RPATH/q

Dynamic segment at offset 0x41c4c contains 20 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library:
[libodbcinst.so.1]
 0x00000001 (NEEDED)                     Shared library: [libc.so.12]
 0x0000000e (SONAME)                     Library soname: [libtdsodbc.so.0]
 0x0000000f (RPATH)                      Library rpath: [/usr/pkg/lib]

So that's it.  Thanks, Patrick!  

--jkl