swig c python
来源:互联网 发布:eclipse java下载哪个 编辑:程序博客网 时间:2024/04/29 18:23
http://www.swig.org/translations/chinese/tutorial.html
/* File : example.c */#include <time.h> double My_variable = 3.0; int fact(int n) { if (n <= 1) return 1; else return n*fact(n-1); } int my_mod(int x, int y) { return (x%y); } char *get_time() { time_t ltime; time(<ime); return ctime(<ime); }/* example.i */ %module example %{ /* Put header files here or function declarations like below */ extern double My_variable; extern int fact(int n); extern int my_mod(int x, int y); extern char *get_time(); %} extern double My_variable; extern int fact(int n); extern int my_mod(int x, int y); extern char *get_time();
swig -python example.i
xsheng@bcxcp-AS-dev01:~/workspace/swig$ gcc -fpic -c example.c example_wrap.c -I /home/ezhao/tools/python-2.7/include/python2.7/
xsheng@bcxcp-AS-dev01:~/workspace/swig$ ld -shared example.o example_wrap.o -o _example.so
现在可以使用如下Python模块 :
>>> import example >>> example.fact(5) 120 >>> example.my_mod(7,3) 1 >>> example.get_time() 'Sun Feb 11 23:01:07 1996' >>>
0 0
- swig c python
- Python与C++,SWIG
- Python调用C/C++(使用SWIG)
- Python 使用C代码——swig
- 在Python中调用C++,使用SWIG
- centos swig 编译c,python调用
- python通过swig调用c程序举例
- Swig:C/C++代码转Python
- 采用SWIG实现python调用C函数
- swig-python
- swig python
- swig-python
- swig python
- SWIG and Python(用SWIG将C/C++封装为Python扩展模块)
- 使用SWIG和Python对C/C++进行单元测试(一)
- 使用SWIG和Python对C/C++进行单元测试(二)
- 使用swig为python添加c扩展总结
- 使用SWIG和Python对C/C++进行单元测试
- 资料汇总
- 在iOS7中修改UISearchBar键盘Return键的类型与IOS6中的不同之处
- 黑马程序员_常用类1
- 计算机发展及现状
- FatFs源码剖析
- swig c python
- codeforces 393A Nineteen
- xcode 弹出 please tell me who you are
- Solr4.4的安装与配置
- log4j
- 手把手教你玩转GDB(一)—牛刀小试:启动GDB开始调试
- apk反编译查看*.java,AndroidManifest.xml,布局xml文件
- 结构体
- 通过子查询进行UPDATE