4

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
  • 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 5 at 23:46
4

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.

  • YES! Thank you very much Gilles! I tried it now and indeed the order is very important. Chaos' answer is wrong! – Al Bundy Jan 28 '16 at 0:14
  • 1
    @AlBundy I'm sorry for the confusion, I misunderstood/misinterpreted the man page man7.org/linux/man-pages/man8/ldconfig.8.html. However I removed my answer. – chaos Jan 28 '16 at 0: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... – Al Bundy Jan 28 '16 at 7:24
1

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

/sbin/ldconfig -v 2>/dev/null | grep :

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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