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() [...] is an alternative: instead of doing a dlopen, it generates and compiles a piece of C code.
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).