C程序到python模块的swig转换流程
程序参考:http://www.swig.org/Doc3.0/SWIGDocumentation.html#Introduction_nn4
0、swig下载与安装
下载链接(http://www.swig.org/download.html)
安装方法(http://www.swig.org/Doc4.0/Preface.html#Preface_installation)
1、编辑待转C程序 example.c
/* File : example.c */
double My_variable = 3.0;
/* Compute factorial of n */
int fact(int n) {
if (n <= 1)
return 1;
else
return n*fact(n-1);
}
/* Compute n mod m */
int my_mod(int n, int m) {
return(n % m);
}
2、编辑swig的转换接口文件 example.i
/* File : example.i */
%module example
%{
/* Put headers and other declarations here */
extern double My_variab

本文介绍了如何使用SWIG将C程序转换成Python模块的过程,包括下载安装SWIG、编辑C源文件、创建SWIG接口文件、运行SWIG转换、编译链接生成动态库以及发布和使用转换后的模块。
最低0.47元/天 解锁文章
521

被折叠的 条评论
为什么被折叠?



