Moving* back to /lib

Chris Adams cmadams at
Fri Apr 9 17:19:19 UTC 2010

Once upon a time, Richard W.M. Jones <rjones at> said:
> On Fri, Apr 09, 2010 at 10:26:01AM -0500, Chris Adams wrote:
> > Once upon a time, Richard W.M. Jones <rjones at> said:
> > > libguestfs builds its appliance on the fly by concatenating together
> > > files [library files, binaries and data files] from the host.  We
> > > express this requirement by mapping the location of those files into
> > > dependencies.
> > 
> > Why can't it just depend on<vesion>, and then use the
> > linker to find the libraries at run-time?
> Because it's not linking with the library, it's copying it (along with
> many other non-library-like files) into an appliance.


$ ldconfig -p | grep "libcrypto\.so\." | sed 's/.* => //'

Granted, it would take another line or two to handle multilib, but
that's it.

If you wanted to get fancy, you could use the C compiler (avoids having
to directly deal with multilib), but that requires -devel packages
installed.  Even better would be to do this at RPM build time; link an
empty program against all of the libraries you need and just install the
resulting no-op binary somewhere.  Then use "ldd" to find all the
dependencies (like the old mkinitrd script did).

$ echo 'main(){}' | cc -lcrypto -o findlib -x c -
$ ldd findlib =>  (0x00007fffdab7c000) => /usr/lib64/ (0x000000354ae00000) => /lib64/ (0x00000038f2200000) => /lib64/ (0x00000038f2a00000) => /lib64/ (0x00000038f3200000)
	/lib64/ (0x00000038f1e00000)

You copy everything from the ldd output (except for the VDSO bit
obviously), which should make sure you get any dependencies (except for
dlopen() libraries, but that is actually hard to handle in an automated

> Now you may think that this is a bad way to build an appliance, but no
> one has come up with any better ideas for that so far.

It isn't hard to find a shared library without hard-coding static paths.
Chris Adams <cmadams at>
Systems and Network Administrator - HiWAAY Internet Services
I don't speak for anybody but myself - that's enough trouble.

More information about the devel mailing list