I was able to reproduce your error with the following specific error message.
__pycache__/_cffi__x46e30051x63be181b.c:157:20: fatal error: add.c: No such file or
directory
#include "add.c"
It seems that cffi
is trying to compile your file from inside the __pycache__
subdirectory, while add.c
is in the current directory. The fix for this is to use the relative path
#include "../add.c"
However, once I fixed that, your declaration was also incorrect, so I fixed that as well, and the following code produces correct results.
from cffi import FFI
ffi = FFI()
ffi.cdef("""
float add(float f1, float f2);
""")
C = ffi.verify("""
#include "../add.c"
""", libraries=[]
)
sum = C.add(1.9, 2.3)
print sum