[pypy-dev] cffi dlopen

Roshan Cherian cherian.rosh at gmail.com
Tue Sep 15 17:01:48 CEST 2015


Thanks Armin and Maciej.

Thanks for replying, let me share my case I have libical.so built into a
path which is set in LD_LIBRARY_PATH.

I have upgraded to pypy2.6.1 with libffi3.2.1 and cffi 1.2.1. I have run
the following:

>export LD_LIBRARY_PATH=./lib
>./pypy/bin/pypy>>
from cffi import FFI
ffi=FFI()
ffi.ctypes('''..
''')
ffi.dlopen('ical')

fails with an error not able to load
ffi.dlopen('libical.so')

>>>>libical=ffi.dlopen('libical.so')
<cffi.api.FFILibrary_libical.so <http://cffi.api.ffilibrary_libical.so/> object
at 0x00007f4f40f8da60>

>>>> import ctypes.util

>>>> libical = ffi.dlopen(ctypes.util.find_library('ical'))

>>>>
libical.ical_set_unknown_token_handling_setting(libical.ICAL_ASSUME_IANA_TOKEN)
I get an error: AttributeError: ical_set_unknown_token_handling_setting

However if I yum install libical and do the above it works just fine,
meaning I don't get a AttributeError, so I believe its a problem in loading
from LD_LIBRARY_PATH. I did see the following:
https://bitbucket.org/cffi/cffi/issues/58/dlopen-ignores-ld_library_path-and-doesnt,
however I don't understand quite well what the solution was

I haven't tried out ffi.verify I am not sure how to load a shared lib using
ffi.verify, I am sorry if my understanding is wrong.

Thanks,
-Roshan

On Tue, Sep 15, 2015 at 5:23 AM, Armin Rigo <arigo at tunes.org> wrote:

> Hi Roshan,
>
> On Tue, Sep 15, 2015 at 8:02 AM, Maciej Fijalkowski <fijall at gmail.com>
> wrote:
> > ffi.dlopen does not require a C compiler, ffi.verify does (which we
> > strongly encourage to use). Note that since cffi 1.0 you only require
> > C compiler to create extensions, you can distribute them without a
> > compiler. See documentation for details
>
> I added more emphasis about that to the documentation's Overview page.
> You can see it at https://bitbucket.org/cffi/cffi/wiki/overview (grep
> for "C compiler").
>
>
> A bientôt,
>
> Armin.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20150915/f8315689/attachment.html>


More information about the pypy-dev mailing list