ffi.dlopen is unable to load shared library - OSError: cannot load library

493 views
Skip to first unread message

Alex Chekunkov

unread,
Nov 18, 2016, 11:21:10 AM11/18/16
to python-cffi
Hey,

I ran into the problem with a python package that uses cffi - the comprehensive description is in https://github.com/nanomsg/nnpy/issues/40. Short summary - when ffi.dlopen loads library ctypes.util.find_library is able to find correct library name, but after that backend.load_library fails with OSError: cannot load library libnanomsg.so.5.0.0

Does anyone have an idea what's going wrong there and how to fix that?

Armin Rigo

unread,
Nov 18, 2016, 11:48:10 AM11/18/16
to pytho...@googlegroups.com
Hi Alex,
Not really. I don't understand how ctypes.util.find_library() manages
to find the library name (it shouldn't look in LD_LIBRARY_PATH); and
then I don't understand why dlopen() *fails* to do the same (it
*should* look in LD_LIBRARY_PATH). Indeed, the line
backend.load_library() in cffi/api.py just calls the C function
dlopen() without any further tweaking of the path.

I guess it's time to read very carefully "man dlopen" and see if there
are extra distribution-specific hacks in there. If all else fails,
you can try to (1) make very sure about what the C-level dlopen() is
called with, possibly with strace; (2) try to reproduce the problem by
writing a custom C program that calls dlopen() with the same
arguments.


A bientôt,

Armin.

Alex Chekunkov

unread,
Nov 18, 2016, 11:54:16 AM11/18/16
to pytho...@googlegroups.com
Hi Armin,

thanks for the proposed options, I'll try them and will get back here if I find something.

Best,
Alex


--
-- python-cffi: To unsubscribe from this group, send email to python-cffi+unsubscribe@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/python-cffi?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "python-cffi" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-cffi/sA7nFP_q6Fw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python-cffi+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages