1

Under the FHS, system packages (e.g. RPMs) install libraries to /usr/lib (or /usr/lib64). Similarly, libraries compiled using the old "configure;make;make install" routine, which are not part of the system distribution, by default get installed to /usr/local/lib (or /usr/local/lib64).

In general it is considered bad form to require users to alter LD_LIBRARY_PATH or ld.so.conf for applications they install. See for example:

http://web.archive.org/web/20060719201954/http://www.visi.com/~barr/ldpath.html

However, shouldn't /usr/local/lib be an exception to this rule?

If that's the case why don't many/most distributions include /usr/local/lib on the library search path by default? So far only ArchLinux seems to have considered this to be bug see http://bugs.archlinux.org/task/20059?project=1&opened=2263 & the related http://bbs.archlinux.org/viewtopic.php?id=99807

Is it more correct for an application that needs a library in /usr/local/lib to include /usr/local/lib in its RPATH or to expect the OS to have that setting already? I dislike the idea of using anything not based on $ORIGIN in the RPATH.

This is not a question of pedantry as it has implications for system stability and how software should be packaged.

closed as primarily opinion-based by Thomas Dickey, GAD3R, Kusalananda, Anthon, Satō Katsura Apr 10 '17 at 6:12

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Debian derivatives include /usr/local/lib by default. – Stephen Kitt Apr 7 '17 at 16:36
  • I think you've hit the nail on the head – Bruce Adams Apr 9 '17 at 0:40
  • I haven't yet found anyone with the opinion /usr/local/lib shouldn't be on the default path. So I am not sure this is actually opinion based. – Bruce Adams Apr 11 '17 at 16:22
2

It has been suggested that /usr/local/lib should be on the default path and it should be considered a 'bug' in Linux variants like Red Hat where it isn't.

This answer https://stackoverflow.com/a/17653893 points out the salient parts of http://linuxmafia.com/faq/Admin/ld-lib-path.html

Many Red Hat-derived distributions don't normally include /usr/local/lib in the file /etc/ld.so.conf. I consider this a bug, and adding /usr/local/lib to /etc/ld.so.conf is a common ``fix'' required to run many programs on Red Hat-derived systems.

I raised this with Red Hat and I now disagree.

Red Hat provided packages are never installed to /usr/local on systems where vendors do install to /usr/local the answer is different. On those systems /usr/local/lib can reasonably be expected to be on the default search path.

Red Hat pointed out that /usr/local/lib should not be on the default search path as any library added there could be picked up by RPM and yum.

I investigated this further. If you install your own version of a system library in /usr/local/lib then it could satisfy a dependency of another system package you install normally via RPM or yum. Obviously this could affect system stability. Worse it would do so quite subtley. yum check could report that you have all the vendor versions of all the packages you need and not notice you have you own version of something significant in /usr/local/lib.

On systems using a different package manager this may not apply.

I don't have a complete answer to what to put in your RPATH. However, I think you should avoid depending on libraries in /usr/local/lib and instead have them installed to /opt (i.e. somewhere you control as part of your installation) wherever practical.

Not the answer you're looking for? Browse other questions tagged or ask your own question.