C 语言
#include <stdio.h>
#include <stdlib.h>
int foo(int a, int b)
{
printf("you input test %d and %d\n", a, b);
return a+b;
}
编译方式
gcc -o libpycall.so -shared -fPIC pycall.c
python
import ctypes
ll = ctypes.cdll.LoadLibrary
lib = ll("./libpycall.so")
lib.foo(1, 3)
print '***finish***'
运行结果