Re: /usr/lib vs. /usr/local/lib

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks all for your help.

After I ran "sudo ldconfig -v", now the linker cache was updated, and
my program is linking to the correct ones in /usr/local/lib :-)

thanks again.
Han

On Sat, Jan 16, 2010 at 3:52 PM, Patrick Horgan <phorgan1@xxxxxxxxx> wrote:
> 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
>
>


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux