Re: Linking against shared objects that reside at different paths on link-time versus runtime?

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

 



On 06/21/2011 05:42 PM, Dun Peal wrote:
> On Tue, Jun 21, 2011 at 11:29 AM, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> wrote:
>> On 21 June 2011 17:24, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> wrote:
>>> Rename it to libbar.so and link to it with "-L/foo -lbar" instead of
>>> giving an absolute path to the .so
>>
>> Actually I think I've misremembered how it works, you might need to
>> create bar.so using -soname=bar.so so that ldd will only make it
>> depend on "bar.so" not the absolute path to the file, and will search
>> for it in the usual locations.
>
> Thanks, unfortunately `bar.so` is a closed-source binary, and `-L/foo
> -lbar` fails.

It shouldn't do.  Can you show us what happened?

> Is there a way to know which `-soname` `bar.so` was assigned?  Maybe
> it's just different from `bar`, and if I just `-l<actual bar.so name>`
> I'd be OK?

readelf -d <libname>

>>> Use an RPATH, e.g. link with -Wl,-rpath,'/baz:$ORIGIN/..' will make it
>>> look in /baz then in ..
>
> Thanks, but I take your answer to mean that I can't link relative to a
> runtime target's environment variable (e.g. `$HOME`)?

Correct.  The path is relative to the location of the executable,
which is usually what you want.

Andrew.


[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