1、 C 代码
1.1 test.c
#include<stdio.h> #include<stdlib.h> #include"test.h" int hello() { printf("hello word 666\n"); return 255; }
1.2 test.h
#include<stdio.h> #include<stdlib.h> int hello();
1.3 调试用的main.cpp
#include"test.h" int main() { hello(); hello(); }
2、将test.c 里面的函数封成.so
gcc -fPIC -shared test.c -o libtest.so
3、python 调库
import os from ctypes import * from ctypes import CDLL,c_int,c_void_p so_path= os.getcwd()+'/libtest.so' print(so_path) c_functin=CDLL(so_path) hello=c_functin.hello hello() hello() hello()
4、目录结构
5、运行结果
热门文章
- 3月14日→20.6M/S|免费节点Clash/SSR/V2rayC订阅链接地址分享
- 关于给动物注射疫苗属于什么行业类别的信息
- 3月17日→20.4M/S|免费节点Clash/SSR/V2rayC订阅链接地址分享
- 4月5日→18.3M/S|免费节点Clash/SSR/V2rayC订阅链接地址分享
- 动物医院收费标准相关规定有哪些要求(动物医院的号码是多少)
- 动物医生证好考吗(动物医师证报考条件)
- 3月7日→22.1M/S|免费节点Clash/SSR/V2rayC订阅链接地址分享
- 猫粮所有品牌app下载(猫粮品牌都有哪些)
- 猫咪领养协议模板简单一点(领养猫的协议是什么样的)
- 宠爱国际待遇怎么样(宠爱国际ceo)