Can I specify where g++looks for libs at runtime?

Dr. David Kirkby david.kirkby@onetel.net
Mon Jun 29 17:21:00 GMT 2009


Joern Rennecke wrote:
>> kirkby@t2:[~] $ ./a.out
>> ld.so.1: a.out: fatal: libstdc++.so.6: open failed: No such file or 
>> directory
>> Killed
>>
>> I'm using the Sun linker, not the GNU one, so it's possible g++ is 
>> sending stuff to the linker to indicate where the libraries are, but 
>> the linker is ignoring them.
>>
>> Ideally I'd like to send something to the Sun linker to day "look in 
>> /usr/local/gcc-4.4.0-sun-linker/lib for libraries too"
>>
>> If I set LD_LIBRARY_PATH, then this will work.
> 
> If you set LD_RUN_PATH before the compilation (more specifically, the
> compile-time linking) of your program, the path from LD_RUN_PATH will
> be recorded in your executable.
> 
> Recording the location of the shared libraries where they were found
> during compile-time linking is not done by default because that will not
> work well when you copy your executable to another machine with a different
> filesystem layout, or if a newer version of the shared library is added in
> a different place.
> 

Thank you. I'm just surprised I need to do this with the compiler I 
installed, as it's necessary with other compilers on the system. I've 
certainly installed binary versions of gcc (from for example Sunfreeware 
or Blastwave) which have not needed this done before.






More information about the Gcc-help mailing list