I have installed some shared libraries to the non-standard directory /usr/lib64/mylib. Then I run sudo ldconfig /usr/lib64/mylib. I can assert by running ldconfig -p that my libraries are indeed cached.
However when I try to compile a certain program that links to a library which links to another library installed in /usr/lib64/mylib I get the following error:
/usr/bin/ld: warning: libmy.so.3, needed by ./build/libtools.so.3.1.0.0, not found (try using -rpath or -rpath-link)
along with a number of undefined references.
This does not happen if I add /usr/lib64/mylib to either /etc/ld.so.conf or to the environment variable LD_LIBRARY_PATH. So what is then the effect of running sudo ldconfig /usr/lib64/mylib?
Edit: I found out that the lines referring to my shared objects get removed when I run ldconfig -p a second time, so they remain there for a very brief moment for some reason.