Subject: Re: "Shared object "libX11.so.6" not found" with MesaDemo
To: None <netbsd-help@NetBSD.org>
From: James K. Lowden <jklowden@schemamania.org>
List: netbsd-help
Date: 06/11/2005 12:25:23
Tom Nakamura wrote:
> weird! everything seems to be as it should (file /usr/X11R6/lib/libX11
> is okay, readelf is showing /usr/pkg/lib only), but ldd is showing 
>          -lX11.6 => /usr/X11R6/lib/libX11.so.6
>          -lXext.6 => /usr/X11R6/lib/libXext.so.6
>          -lX11.6 => not found
>          -lXext.6 => not found
> ... could this possibly be right? but setting LD_LIBRARY_PATH to
> /usr/X11R6/lib solves the problem...

Is that the complete output of ldd?  

An ELF shared object can have a built-in rpath, too, just like an
executable.  Maybe there's a library A that loads a library B, and A lacks
an rpath to B.  

On my system, I see this:

$ readelf -d /usr/X11R6/lib/libX11.so.6  \
             /usr/X11R6/lib/libXext.so.6 \
	|sed -ne'/^File/,/RPATH/p'

File: /usr/X11R6/lib/libX11.so.6
Dynamic segment at offset 0xba654 contains 18 entries:
  Tag        Type                         Name/Value
 0x0000000e (SONAME)                     Library soname: [libX11.so.6]
 0x0000000f (RPATH)                      Library rpath: [/usr/X11R6/lib]

File: /usr/X11R6/lib/libXext.so.6
Dynamic segment at offset 0xc430 contains 19 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libX11.so.6]
 0x0000000e (SONAME)                     Library soname: [libXext.so.6]
 0x0000000f (RPATH)                      Library rpath: [/usr/X11R6/lib]

From your ldd(1) output, I would expect both the executable and libXext to
load libX11, each by its own RPATH.  Could that be the source of the
difficulty?  

--jkl


> 
> On Fri, 10 Jun 2005 00:07:46 -0400, "James K. Lowden"
> <jklowden@schemamania.org> said:
> > Tom Nakamura wrote:
> > > I'm trying to run the demos in MesaDemo, but am getting "Shared
> > > object "libX11.so.6" not found". I know libX11.so.6 is in
> > > /usr/X11R6/lib but setting LD_LIBRARY_PATH according does not help.
> > > I'm using a current pkgsrc on i386. Funny thing is I think it worked
> > > fine with 2005Q1 (or earlier, not sure). Any ideas?
> > 
> > Does yours look like this:
> > 
> > $ file /usr/X11R6/lib/libX11.*
> > /usr/X11R6/lib/libX11.a:      current ar archive
> > /usr/X11R6/lib/libX11.so:     symbolic link to `libX11.so.6.2'
> > /usr/X11R6/lib/libX11.so.6:   symbolic link to `libX11.so.6.2'
> > /usr/X11R6/lib/libX11.so.6.2: ELF 32-bit LSB shared object, Intel
> > 80386, version 1 (SYSV), not stripped
> > 
> > If so, what do:
> > 
> > 	$ ldd $(command -v MesaDemo)
> > 	$ readelf -d $(command -v MesaDemo) |grep rpath
> > 
> > show?  (I'm assuming 'MesaDemo' is the binary in question.)  readelf
> > should show an RPATH to /usr/pkg/lib if the executable was built in
> > pkgsrc.  
> > 
> > --jkl