Subject: Re: Why do I need to add an entry into ld.so.conf?
To: None <port-i386@netbsd.org>
From: Rui Paulo <rpaulo@netbsd-pt.org>
List: port-i386
Date: 03/23/2005 19:52:00
On 2005-03-23, Phil Pereira <phil@bsdnexus.com> wrote:
> Hey all,
>
> I'm a little confused by an issue I'm having.
>
> The pkgsrc collection builds fine and I've *never* needed to change anything to have an app complie and work.
>
> Yesterday I downloaded the app wmswallow and tried to build it. All seemed to go well, and the app itself compiled. However - upon trying to run the program I was told that a certain .so file could not be found :(
>
> I used "ldd" to determine that, in fact, a couple of dependencies could not be found.
>
> I added "/usr/X11R6/lib" to ld.so.conf and all worked fine - including the app. "ldd" showed links to the correct dependencies.
>
> My question : If I *never* need to add anything to ld.so.conf to compile an app in pkgsrc, why did I need to add it for a program I compiled myself?  What am I missing? Or what did I get wrong?
>
> Many thanks all
>
> Phil.
>

When building packages, pkgsrc adds linker flags to gcc command line,
so, when the program is executed, some library paths are hardcoded in
ELF's .dynamic section:
$ objdump -p /usr/pkg/bin/xscreensaver     

/usr/pkg/bin/xscreensaver:     file format elf32-i386

[program header skipped]

Dynamic Section:
  NEEDED      libintl.so.0
  NEEDED      libXmu.so.6
  NEEDED      libXss.so.1
  NEEDED      libXinerama.so.1
  NEEDED      libXxf86vm.so.1
  NEEDED      libXrandr.so.2
  NEEDED      libXrender.so.1
  NEEDED      libXxf86misc.so.1
  NEEDED      libXt.so.6
  NEEDED      libSM.so.6
  NEEDED      libICE.so.6
  NEEDED      libX11.so.6
  NEEDED      libXext.so.6
  NEEDED      libcrypt.so.0
  NEEDED      libc.so.12
  RPATH       /usr/pkg/lib:/usr/X11R6/lib
[...]

Also, dinamically linked objects continue to check ld.so.conf even if
they have RPATH set in ELF's dynamic section.

Hope this helps.


-- 
 Rui Paulo <rpaulo@netbsd-pt.org>        http://www.netbsd-pt.org/users/rpaulo/