from cffi import FFI
ffi = FFI()
header_path = '/usr/include/libelf.h'
with open(header_path) as f:
ffi.cdef(f.read())
lib = ffi.dlopen('/usr/local/lib/libelf.so')
The code above is the one I am actually struggling with. For using some functions of libelf, I need to wrap the library and the header. After long time of recherche this seems to be the right approach to do that.
But I get a parsing error:
cannot parse "#ifndef _LIBELF_H"
It seems that all kinds these expressions cause parsing errors. How can I solve this problem? Or is there another approach of wrapping both: library and header?