This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


On 21 June 2011 17:29, Jonathan Wakely wrote:
> On 21 June 2011 17:24, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>> On 21 June 2011 17:15, Dun Peal wrote:
>>> Hello!
>>>
>>> I have the following line in a build script:
>>>
>>> ? ?g++ [...] -Bdynamic /foo/bar.so
>>>
>>> This line results in a binary which when analyzed with `ldd(1)`, shows
>>> a dependency on `/foo/bar.so`.
>>>
>>> The problem is that the link-time and runtime platforms are not the
>>> same: at link-time, `bar.so` resides under `/foo`, while at runtime it
>>> lives under `/baz`.
>>>
>>> 1) Is there a way to link `bar.so` such that at compile (more
>>> precisely, link) time, it would be found at the former, while at
>>> runtime it would be found on the latter?
>>
>> 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

Bah, that should say "ld" not "ldd"

I'm going to give up now before I type any more nonsense!


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]