Alfred M. Szmidt wrote:
Is "/usr/local/lib" still searched before "/usr/lib" by GCC by
default? If not, is there a way to force GCC to search
/usr/local/lib first?
GCC does search /usr/local/lib before /usr/lib (you can use gcc
-print-search-dirs to see the exact details for your configuration)
when linking, but your dynamic loader might not (which is what ldd
calls, and what is used when you run the program). I think just
modifying /etc/ld.so.conf and putting /lib before /usr/local/lib (or
adding them in that order) should do the trick for you. Don't forget
to run ldconfig after modifying ld.so.conf.
To get even trickier, my linux system has this for the only line:
include /etc/ld.so.conf.d/*.conf
That tells me to go into /etc/ld.so.conf.d where I have a file named
libc.conf (the name doesn't matter, but it has to end with .conf to
match the wild card in /etc/ld.so.conf
Inside /etc/ld.so.conf.d/libc.conf I have the single line:
/usr/local/lib
I could have added that line to the bottom of /etc/ld.so.conf as well.
Then, every time the contents of any directories containing libraries
changes, you have to run ldconfig as root and that fixes every thing
up. To learn more read the man pages for ldd, ld.so, and ldconfig.
Patrick