Re: Developing against $HOME/lib libraries and LD_LIBRARY_PATH

Thomas Jahns <[email protected]>
Newsgroups gmane.comp.gnu.libtool.general
Message-ID <[email protected]>
Posting again, since at the first attempt I only sent directly to Paul.

On 11/22/17 15:45, Paul "LeoNerd" Evans wrote:
> On Thu, 16 Nov 2017 14:49:01 -0500
> Nick Bowler <[email protected]> wrote:
> 
>> If that is not happening then maybe the libraries and/or programs are
>> being linked incorrectly, or perhaps there's a bug in libtool.
>>
>> Example:
>>
>> build+install libfoo to non-system location:
>>    % libtool --tag=CC --mode=compile gcc -c foo.c
>>    % libtool --tag=CC --mode=link gcc -rpath /tmp/instlib -o libfoo.la
>> foo.lo % libtool --mode=install cp libfoo.la /tmp/instlib
>>
>> build libbar, linked against libfoo:
>>    % libtool --tag=CC --mode=compile gcc -c bar.c
>>    % libtool --tag=CC --mode=link gcc -rpath /usr/local/lib -o
>> libbar.la \ bar.lo /tmp/instlib/libfoo.la
>>
>> build application linked against uninstalled libbar:
>>    % libtool --tag=CC --mode=compile gcc -c app.c
>>    % libtool --tag=CC --mode=link gcc -o app app.lo libbar.la
>>
>> Inspection of results:
>>    % ldd .libs/app
>>    [...]
>>    libbar.so.0 => not found
>>    libfoo.so.0 => /tmp/instlib/libfoo.so.0 (0x00007fec8f7a9000)
>>
>>    [we see that that the executable has the nonstandard location for
>> libfoo, and libbar is not installed so it is not found by ldd, and
>> finally...]
>>
>>    % libtool --mode=execute ./app
>>    [works correctly]
> 
> Ah interesting. I see a number of `-rpath` arguments in theabove, which
> I don't have in my case. I wonder if that explains it. Should the .pc
> file from the first library be emitting that as part of the --libs
> output then?

The -rpath argument is for libtool (to tell it where the library will be 
installed). To tell libtool (or ld) where to search for libraries at run-time 
(if no .la files are installed) one needs to add -R or -Wl,-rpath options.

Regards, Thomas

_______________________________________________
https://lists.gnu.org/mailman/listinfo/libtool
smime.p7s (application/pkcs7-signature, 4.6 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.