libtool
[Top][All Lists]
Advanced

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

ld --rpath problem using libtool


From: Richard Hacker
Subject: ld --rpath problem using libtool
Date: Mon, 7 Jan 2008 08:59:37 +0100
User-agent: KMail/1.9.5

Hi all,

I'm experiencing some trouble using libtool inside the GNU autotools 
collection. My compiled objects do not find their shared libraries that are 
installed in non-standard library paths.

I wrote a C++ library, called rtcom for argument's sake, and used SWIG to make 
it available as a Python module, rtcom.py. Now SWIG generates some glue C++ 
code which should be compiled as _rtcom.so. This shared object must lie 
somewhere in Python's search path. _rtcom.so obviously needs to link at 
runtime to rtcom.so, the original C++ library. 

For various reasons, however, I do not want to install rtcom.so in the 
standard library directories. This generally is not a problem, as linking an 
object using ld --rpath <LibraryPath>, it is possible to tell the dynamic 
linker where to find a shared library.

As I understand it, this is a typical libtool task. I used the following 
Makefile.am to generate the tools:

############## Makefile.am #########################
BUILT_SOURCES = rtcom_wrap.cpp rtcom_wrap.h
SWIG_SOURCES = rtcom.i

pkgpython_PYTHON = rtcom.py
pkgpyexec_LTLIBRARIES = _rtcom.la
_rtcom_la_SOURCES = $(BUILT_SOURCES) $(SWIG_SOURCES)
_rtcom_la_CPPFLAGS = $(SWIG_PYTHON_CPPFLAGS) -I$(top_srcdir)
_rtcom_la_LDFLAGS = -module
_rtcom_la_LIBADD = ../librtcom.la

-include $(DEPDIR)/rtcom_wrap.d
rtcom_wrap.cpp: $(SWIG_SOURCES)
        $(SWIG) $(SWIG_PYTHON_OPT) -I$(top_srcdir) \
                -MMD -MF $(DEPDIR)/rtcom_wrap.d -o $@ $<

rtcom_wrap.h: $(SWIG_SOURCES)
        $(SWIG) $(SWIG_PYTHON_OPT) -I$(top_srcdir) \
                -MMD -MF $(DEPDIR)/rtcom_wrap.d -oh $@ $<
##################################################

make install calls:
../libtool --mode=install /usr/bin/install -c  '_rtcom.la' \
        '/opt/etherlab/lib/python2.5/site-packages/rtcom/_rtcom.la'
which in turn calls:
/bin/sh ../libtool  --tag=CXX --mode=relink g++ -g -O2 \
        -o _rtcom.la \
        -rpath /opt/etherlab/lib/python2.5/site-packages/rtcom \
        -module _rtcom_la-rtcom_wrap.lo ../librtcom.la -lexpat
The relink calls g++, however _without_ the necessary 
"-Wl,--rpath -Wl,/opt/etherlab/lib" options to g++

The complete install log is attached.

It is then no surprise that loading the module under Python fails:
---------------------------------------------------
>>> import sys
>>> sys.path.append('/opt/etherlab/lib/python2.5/site-packages/rtcom')
>>> import rtcom
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/etherlab/lib/python2.5/site-packages/rtcom/rtcom.py", line 5, in 
<module>
    import _rtcom
ImportError: librtcom.so.2: cannot open shared object file: No such file or 
directory
---------------------------------------------------


As a workaround, I replace _rtcom_la_LDFLAGS in Makefile.am with:
_rtcom_la_LDFLAGS = -module -Wl,--rpath -Wl,$(libdir)
Then it works.

As I understand it, this should be libtool's task. All the necessary 
information about where rtcom.so is installed is contained in the rtcom.la 
file. What am I missing out on here?

My autotools configuration is:
autoconf-2.60-21
automake-1.9.6-35
libtool-1.5.22-34

I am also using ac_pkg_swig.m4  ac_python_devel.m4  swig_enable_cxx.m4  
swig_python.m4 downloaded from http://autoconf-archive.cryp.to/

Many thanks in advance for any help.

- Richard

Attachment: install.log
Description: Text Data


reply via email to

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