-----Original Message----- From: lxml-bounces@lxml.de [mailto:lxml-bounces@lxml.de] On Behalf Of jholg@gmx.de Sent: Tuesday, April 05, 2011 3:27 AM To: Tim Arnold; lxml@lxml.de Subject: Re: [lxml] libxml2 library not found error
Hi,
hi, I'm installing lxml-2.3 on FreeBSD 8.2. Been working on this for a couple of days... I installed the latest libxml2, libxslt, Python2.7 in a non-standard location, '/AppDocs/local'
[...]
from lxml import etree Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: Shared object "libxml2.so.9" not found, required by "etree.so"
The file libxml2.so.9 is in the /AppDocs/local/lib directory. More info: lxml2-config: -L/AppDocs/local/lib -lxml2 -lz -lpthread -lm -I/AppDocs/local/include/libxml2 2.7.8
xslt-config -L/AppDocs/local/lib -lxslt -lxml2 -lz -lpthread -lm -I/AppDocs/local/include -I/AppDocs/local/include/libxml2 1.1.26
Never been on FreeBSD, but anyhow:
You probably need to add your non-standard locations to the runtime library search path.
Try running with your lib install directory added to LD_LIBRARY_PATH (guess this also works on FreeBSD?), i.e. LD_LIBRARY_PATH=/AppDocs/local/lib python, to see if this makes a difference.
My xslt-config looks like this:
/apps/prod/libxslt/current/bin/xslt-config --libs - L/apps/prod/libxslt/1.1.14/lib -L/apps/prod/libxml2/2.6.20/lib - R/apps/prod/libxml2/2.6.20/lib -L/apps/prod/zlib/1.2.3/lib - R/apps/prod/zlib/1.2.3/lib -lxslt -lxml2 -lz -lpthread -lsocket -lnsl -lm
Note the -R<path> stuff which causes etree.so to have this stuff added to its runtime lib search path: $ elfdump -d lxml/etree.so
Dynamic Section: .dynamic index tag value [0] NEEDED 0x2a98 libxslt.so.1 [1] NEEDED 0x2aa5 libexslt.so.0 [2] NEEDED 0x2ab3 libxml2.so.2 [3] NEEDED 0x2ac0 libz.so [4] NEEDED 0x2ac8 libm.so.1 [5] RPATH 0x2af1 /apps/prod//libxml2/2.6.32/lib:/apps/prod//libxslt/1.1.23/lib:/apps/prod/l ib
Btw: Does running /AppDocs/local/bin/xsltproc work for you or do you also get the dependency problem?
So what you could do is: * build libxml2/libxslt in a way that they add the runtime lib search path into their config, which lxml uses in turn (probably not an option if you don't build yourself but just install) * use LD_LIBRARY_PATH (quick but ugly imho) * use ldconfig (or the FreeBSD analogon?) which is common on Linux to add your non-standard paths to the runtime linker search path * set the rpath as an option to setup.py's build_ext command (or put it into in setup.cfg), e.g. setup.py build_ext --rpath=<your path>
Holger
hi Holger, thanks for showing me those settings. I finally got it! This may be overkill, but here's what I did after installing Python2.7.1: export LD_LIBRARY_PATH="/AppDocs/local/lib" export LD_RUN_PATH="/AppDocs/local/lib" export CFLAGS="-fPIC -L/AppDocs/local/lib -R/AppDocs/local/lib" with those settings (and --prefix=/AppDocs/local on configure), libxml2, libxslt: (make install) lxml: setup.py (build install) It was trial and error, but your message confirmed that it was possible and now I can parse again, using my local libs:
xslt-config --libs -L/AppDocs/local/lib -lxslt -lxml2 -lz -lpthread -lm xslt-config --cflags -I/AppDocs/local/include -I/AppDocs/local/include/libxml2
xml2-config --libs -L/AppDocs/local/lib -lxml2 -lz -lpthread -lm xml2-config --cflags -I/AppDocs/local/include/libxml2
and elfdump -d says, among other things: entry: 7 d_tag: DT_RPATH d_val: /AppDocs/local:/AppDocs/local/lib thanks again, --Tim