[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: inter-library-dependency, how?
From: |
Nick Bowler |
Subject: |
Re: inter-library-dependency, how? |
Date: |
Fri, 9 Sep 2011 12:01:52 -0400 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On 2011-09-09 17:56 +0200, Christian Rössel wrote:
> I want to build a program that depends on a libtool library that depends
> on a non-libtool library that needs rpath information to be found a runtime.
>
> My Makefile.am looks like this:
> lib_LTLIBRARIES = libfoo.la
> libfoo_la_SOURCES = libfoo.c libfoo.h
> libfoo_la_CPPFLAGS = -I/opt/packages/papi/4.1.2.1/include
> libfoo_la_LDFLAGS = -L/opt/packages/papi/4.1.2.1/lib
> libfoo_la_LIBADD = -lpapi
>
> bin_PROGRAMS = foo
> foo_SOURCES = foo.c
> foo_LDADD = libfoo.la
[...]
> Building and linking succeeds, but trying to run ./foo leads to
> ./foo: error while loading shared libraries: libpapi.so: cannot open
> shared object file: No such file or directory
>
> The library is in the location specified by libfoo_la_LDFLAGS (.a and
> .so). But the rpath /opt/packages/papi/4.1.2.1/lib is not available. How
> do I get it into foo without specifying it as
> foo_LDFLAGS = -Wl,-rpath /opt/packages/papi/4.1.2.1/lib?
Looking at https://www.gnu.org/software/libtool/manual/libtool.html#Link-mode,
-R libdir
If output-file is a program, add libdir to its run-time path. If
output-file is a library, add -Rlibdir to its dependency_libs, so
that, whenever the library is linked into a program, libdir will
be added to its run-time path.
So it seems that adding -R/opt/packages/papi/4.1.2.1/lib to
libfoo_la_LDFLAGS would do the trick?
Cheers,
--
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)