Ctypes does not find libraries installed in Fink in / sw / lib

ctypesdoes not find libraries installed through fink that live under /sw/lib/unless I explicitly give the full path to the libraries

>>> import ctypes
>>> ctypes.CDLL('libgoffice-0.8.dylib')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/sw/lib/python2.7/ctypes/__init__.py", line 353, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(libgoffice-0.8.dylib, 6): image not found
>>> ctypes.CDLL('/sw/lib/libgoffice-0.8.dylib')
<CDLL '/sw/lib/libgoffice-0.8.dylib', handle 336500 at 2b10b0>
>>>

Compiling against these libraries using gcc, however, works great; they are always found. Why is ctypesthere no placement of these libraries and what can I do to find them?

This is on OS X 10.6.8 with Fink Python 2.7 installed /sw/bin/python2.7.

+1
source share
1 answer

The problem is that fink never sets a variable LD_LIBRARY_PATH. ctypesuses dlopen()which by default will not search in /sw/lib. On the dlopenman page :

dlopen() Mach-O . , -- , . LD_LIBRARY_PATH, DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH. ables . DYLD_FALL- BACK_LIBRARY_PATH - $HOME/lib;/usr/local/lib;/usr/lib. dlopen() , .

, , , , .profile, .bash_profile .bashrc

export LD_LIBRARY_PATH=/sw/lib:"${LD_LIBRARY_PATH}"

, fink /sw/lib, /sw/lib/mysql. , , dlopen() LD_LIBRARY_PATH. MySQL , :

export LD_LIBRARY_PATH=/sw/lib:/sw/lib/mysql:"${LD_LIBRARY_PATH}"
+2

All Articles