[Top][All Lists]

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

Re: Developing against $HOME/lib libraries and LD_LIBRARY_PATH

From: Nick Bowler
Subject: Re: Developing against $HOME/lib libraries and LD_LIBRARY_PATH
Date: Thu, 16 Nov 2017 14:49:01 -0500

On 11/16/17, Paul "LeoNerd" Evans <address@hidden> wrote:
> I'm developing two different C libraries; lets just call them A and B.
> A is fairly standalone, and B depends on A.
> But now suppose I have a possible change I want to make that needs
> edits in both libraries. I don't want to build a new system package yet
> and upset all the other users on this box. That's fine, I can just
> install library A into my $HOME directory using
>   $ make install PREFIX=$HOME
> In order to be able to test programs that use library A, I'm going to
> need to set LD_LIBRARY_PATH now so they can find the library here in
> preference to the system-installed one, so in my .profile I use

If A and B are libtool libraries, and B is linked with libtool against the
installed version of A in $HOME, and your programs are linked against B
also using libtool, then this should all "just work".  Libtool should be
automatically inserting the necessary linker flags to use the version of
A installed in $HOME (e.g., by setting DT_RUNPATH to $HOME/lib on ELF

>   export LD_LIBRARY_PATH=$HOME/lib

... and there should be no need to do this, in part because hacks like
this cause the type of problems you are seeing.

If that is not happening then maybe the libraries and/or programs are
being linked incorrectly, or perhaps there's a bug in libtool.


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 foo.lo
  % libtool --mode=install cp /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 \
            bar.lo /tmp/instlib/

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

Inspection of results:
  % ldd .libs/app
  [...] => not found => /tmp/instlib/ (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]


reply via email to

[Prev in Thread] Current Thread [Next in Thread]