① Create a C Language file
cfun.c
int product(int a, int b) { return a * b; }
② Compile it and create a shared library file
gcc -o hxxlib.so --shared -fPIC cfun.c
③ stay python File using the generated shared library file
from ctypes import * c_file = 'hxxlib.so' c_fun = CDLL(c_file) a = 2 b = 5 print(c_fun.product(a,b))