Meador Inge added the comment: On Linux gcc and ld are used to implement 'find_library' and 'dlopen' is used to implement 'CDLL'. ld searches /usr/local/lib. 'dlopen' might not if the LD_LIBRARY_PATH isn't set up to do so. For example:
[meadori@li589-207 cpython]$ ls /usr/local/lib libfoo.so libfoo.so.1 libfoo.so.1.0 linode [meadori@li589-207 cpython]$ ./python Python 3.4.0a0 (default:d6213012d87b, Jul 23 2013, 01:00:24) [GCC 4.7.2 20120921 (Red Hat 4.7.2-2)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from ctypes import * >>> import ctypes.util >>> ctypes.util.find_library('foo') 'libfoo.so.1' >>> CDLL(_) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/meadori/src/cpython/Lib/ctypes/__init__.py", line 351, in __init__ self._handle = _dlopen(self._name, mode)OSError: libfoo.so.1: cannot open shared object file: No such file or directory >>> quit() [meadori@li589-207 cpython]$ echo $LD_LIBRARY_PATH [meadori@li589-207 cpython]$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib [meadori@li589-207 cpython]$ ./python Python 3.4.0a0 (default:d6213012d87b, Jul 23 2013, 01:00:24) [GCC 4.7.2 20120921 (Red Hat 4.7.2-2)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> from ctypes import * >>> import ctypes.util >>> ctypes.util.find_library('foo') 'libfoo.so.1' >>> CDLL(_) <CDLL 'libfoo.so.1', handle 28e4b50 at 7f31e062b608> I am OK with this behavior in ctypes since it matches the system behavior with 'gcc' and 'dlopen'. So, I would fixup LD_LIBRARY_PATH or /etc/ld.so.conf if you want /usr/local/lib to be searched at load time. ---------- nosy: +meador.inge _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18502> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com