0

Say I need to use a few functions from a shared library, e. g. libfoo.so, from python code. I figured the cffi module could help me, especially as it seems to support opaque types if one uses the verify() function.

I did not fully understand though, what the documentation means by

verify() [...] is an alternative: instead of doing a dlopen, it generates and compiles a piece of C code.

Do I have to recompile the entire libfoo.so? Or just a certain part (relevant parts of the header)? If the latter is the case, is this significantly less of a hassle in terms of dependencies, configuration options, ... ?

J.J. Hakala
  • 6,136
  • 6
  • 27
  • 61
langlauf.io
  • 3,009
  • 2
  • 28
  • 45

1 Answers1

1

No, ffi.verify() (as well as ffi.set_source() in the soon-to-be-released cffi 1.0) generates and compiles a lightweight C wrapper which calls your existing library. The C wrapper contains regular C code that calls the library functions, so as usual with C, the library doesn't need to be recompiled in order to be used---but, also as usual with C, you need to have the headers of that library installed (typically from a package called something like libfoo-dev from your OS distribution).

Armin Rigo
  • 12,048
  • 37
  • 48
  • Thank you for you answer. So I am right to assume that compiling this 'wrapper' only needs the header files of the libfoo library, but not all the dependencies which were initially needed to compile libfoo? – langlauf.io May 10 '15 at 09:29