1.c模块
helloworld.c
#include<stdio.h>
int test() {
printf("hello world!\n");
return 0;
}
complie.sh编译
gcc helloWorld.c -fPIC -shared -o libhello.so
2.Python main.py
import ctypes
so = ctypes.CDLL("./libhello.so")
so.test()
运行
python main.py
hello world!
网友评论