7

I am wondering if I can keep the entries in /etc/ld.so.conf sorted.

My ld.so.conf looks now like this:

/usr/X11R6/lib64/Xaw3d
/usr/X11R6/lib64
/usr/lib64/Xaw3d
/usr/X11R6/lib/Xaw3d
/usr/X11R6/lib
/usr/lib/Xaw3d
/usr/x86_64-suse-linux/lib
/usr/local/lib
/opt/kde3/lib
/usr/local/lib64
/opt/kde3/lib64
/lib64
/lib
/usr/lib64
/usr/lib
/usr/local/cuda-6.5/lib64

When I sort it would look like this - can I safely do it or are they some dependencies which I would "destroy" with the sort?

/lib
/lib64
/opt/kde3/lib
/opt/kde3/lib64
/usr/X11R6/lib
/usr/X11R6/lib/Xaw3d
/usr/X11R6/lib64
/usr/X11R6/lib64/Xaw3d
/usr/lib
/usr/lib/Xaw3d
/usr/lib64
/usr/lib64/Xaw3d
/usr/local/cuda-6.5/lib64
/usr/local/lib
/usr/local/lib64
/usr/x86_64-suse-linux/lib
include /etc/ld.so.conf.d/*.conf
chaos
  • 47,463
  • 11
  • 118
  • 144
Peter VARGA
  • 992
  • 3
  • 11
  • 28
  • Why the second version has an "include", while the first doesn't? All mine has is this "include" line. I'm not even sure how to include other directories. – Rodrigo Jan 05 '19 at 23:46

2 Answers2

10

The entries in /etc/ld.so.conf are searched in order. Therefore, order matters.

This only matters if the same library name (precisely speaking, the same SONAME) is present in multiple directories. If there are directories that you are absolutely sure will never contain the same library then you can put them in the order you prefer.

In particular this means that directories in /usr/local should come before directories outside /usr/local, since the point of these directories is to have priority over the default system files. Among distribution-managed directories, it probably doesn't matter.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
  • YES! Thank you very much Gilles! I tried it now and indeed the order is very important. Chaos' answer is wrong! – Peter VARGA Jan 28 '16 at 00:14
  • 1
    @AlBundy I'm sorry for the confusion, I misunderstood/misinterpreted the man page http://man7.org/linux/man-pages/man8/ldconfig.8.html. However I removed my answer. – chaos Jan 28 '16 at 00:42
  • @chaos We are all human :-). I appreciate your honesty. There are other babies in the forum which do not admit any mistake and just do not reply... – Peter VARGA Jan 28 '16 at 07:24
1

In order to verify or check the order run this command:

/sbin/ldconfig -v 2>/dev/null | grep :
gollum
  • 775
  • 5
  • 7