First, let`s write one simple function using C and generate a shared library file. Let`s say the file name is — function.c.
cc -fPIC -shared -o libfun.so function.c
Usage ctypes (external function interface) libraries for calling a C function from Python
The above statement will generate a shared library named libfun.so. Now let`s see how to use it in Python. In python, we have one library named ctypes. Using this library, we can use the C function in Python.
Let`s say the file name is — function.py.
| tr> |