Hi Nick,
thanks for the quick response.
Am 09.09.2011 18:01, schrieb Nick Bowler:
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?
Well, like the documentations says, -R/opt/packages/papi/4.1.2.1/lib is
added to the dependency_libs:
dependency_libs=' -R/opt/packages/papi/4.1.2.1/lib
-L/opt/packages/papi/4.1.2.1/lib -lpapi'
But when I link libfoo.la into foo, nothing is added to foo's runpath:
libtool: link: gcc -g -O2 -o foo foo.o ./.libs/libfoo.a
-L/opt/packages/papi/4.1.2.1/lib -lpapi
So, the problem remains. Any help appreciated.