[OPEN-ILS-DEV] am I close?

Jeroen Ruigrok van der Werven asmodai at in-nomine.org
Thu May 10 15:36:04 EDT 2007


-On [20070510 21:23], Don McMorris (don.mcmorris at gmail.com) wrote:
> Dan suggests the LD_LIBRARY_PATH because of some "non-standard" file
> naming not picked up by ldconfig (IE: the files that aren't lib*.so).
> Since I'm not a programmer, what would you suggest as an alternate,
> more correct resolution? (so that we may update the docs).

I need to verify what I am going to write here since reading about OMF, a.out,
COFF/PE, and ELF over the past week and everything involved with linkers and
loaders I am apt to be confusing things now.

Ldconfig is the loader's way of knowing where to looking for resolving
libraries and their symbols (and do fancy things like relocations, et cetera).

Now, if you have a library in /usr/local/lib and ldconfig knows nothing about
it any binary linked to a library in /usr/local/lib will not work due to
unknown or undefined symbols. You can easily see which libraries a binary
expects with 'ldd':

[21:23] [root at oni] (515) {0} # ldd /usr/local/bin/python
/usr/local/bin/python:
        libutil.so.5 => /lib/libutil.so.5 (0x28139000)
	libm.so.4 => /lib/libm.so.4 (0x28145000)
	libpthread.so.2 => /lib/libpthread.so.2 (0x2815e000)
	libc.so.6 => /lib/libc.so.6 (0x28182000)

So you generally add something to a ldconfig configuration file to let it know
about the necessary directories. And then you either merge in that directory
or regenerate the cache (ldconfig -m and ldconfig -R typically, ldconfig or
ldconfig -r showing the current runtime configuration).

Now, with using LD_LIBRARY_PATH it gets prepended to any compiled in paths AND
the system default paths. Ergo, those directories get searched before standard
ldconfig's or the binary's own. This would ordinarily not be much of a problem
were it not that LD_LIBRARY_PATH is typically set system-wide or for root and
thus interferes with normal system behaviour.

The solution is to embed the right directories through flags passed to the
linker, typically done as LDFLAGS during the build. For GCC you can use
-Wl,-rpath=<directory-to-look-in>.

-- 
Jeroen Ruigrok van der Werven <asmodai(-at-)in-nomine.org> / asmodai
イェルーン ラウフロック ヴァン デル ウェルヴェン
http://www.in-nomine.org/ | http://www.rangaku.org/
The earth laughs in flowers...


More information about the Open-ils-dev mailing list