Compiling software and the dynamic loader path

jdavidb on 2006-09-29T21:23:38

One of the most annoying things to me in installing many pieces of software, including many Perl modules, is that often the maintainers seem to not understand the concepts expressed here (here until recently ... what in the world happened?). Usually, there is no readily apparent means of setting LD_RUN_PATH and/or -R options in the compilation path, although often the software authors are happy to tell you that you'll probably need to set LD_LIBRARY_PATH in order to get their software to run.


This is a common problem

Phred on 2006-09-29T22:26:45

This is one of the most common issues I run into when installing software where the libraries are someplace other than /usr/lib (often happens with x64 based platforms which use /usr/lib64). The best solution I've found (at least on distros that support it) is to add the library path to /etc/ld.so.conf.

Any suggestions on what to do besides LD_LIBRARY_PATH when you need to link against a library in an oddball place like /opt/custom/magicfoo/lib or something similar? I'm all ears :)

Re:This is a common problem

jdavidb on 2006-10-02T13:03:18

The best solution I've found (at least on distros that support it) is to add the library path to /etc/ld.so.conf

I've just discovered the document I linked to is not the same as the original. If you can hunt down the original (try Internet archive, I can't as I'm at work and it's blocked :P ), it's a must read, and it talks about ld.so.conf and why it's a bad idea. In short, what about when you need something linked against one specially compiled version of libjunk.so in /usr/local/junk and something else linked against a differently compiled version of libjunk.so in /opt/apps/junk?

Theoretically, when you run the linker, you can use a -R option or the LD_RUN_PATH environment variable to hardwire the proper location for libraries into the executable. In practice, what you really need is something to pass to configure or Makefile.PL or what have you -- and it's just not there! The people who set up these config scripts don't understand the need. It's a mess. (Also, when you get a lot of library-related options on the gcc or linker line, it seems to get really confused. I'm sure that the truth is that I get really confused and the linker does just what it's supposed to do -- but it's very order-dependent in a strange way, and I don't understand it, yet.)