python扩展_swig例子
来源:互联网 发布:matlab 离散数据滤波 编辑:程序博客网 时间:2024/05/21 09:54
1.
编写example.c
编写example.c
//<--------example.c------------------
/* File : example.c */
/* A global variable */
double Foo = 3.0;
double Foo = 3.0;
/* Compute the greatest common divisor of positive integers */
int gcd(int x, int y) {
int g;
g = y;
while (x > 0) {
g = x;
x = y % x;
y = g;
}
return g;
}
int gcd(int x, int y) {
int g;
g = y;
while (x > 0) {
g = x;
x = y % x;
y = g;
}
return g;
}
//>--------example.c------------------
2.
编写example.i
编写example.i
//<-------------example.i---------------
/* File: example.i */
%module example
%module example
extern int gcd(int x, int y);
extern double Foo;
extern double Foo;
//>-------------example.i---------------
3.
运行如下命令,即会生成example_wrap.c:
swig -python example.i
运行如下命令,即会生成example_wrap.c:
swig -python example.i
4.
在VC6中创建一个windows dll工程(注意不是console),把example.c和example_wrap.c加入工程,
并设置生成的dll名称为 _example.dll(注意要有下划线),然后编译。
在VC6中创建一个windows dll工程(注意不是console),把example.c和example_wrap.c加入工程,
并设置生成的dll名称为 _example.dll(注意要有下划线),然后编译。
5.
将上一步生成的dll拷贝到python相应目录下。
将上一步生成的dll拷贝到python相应目录下。
6.
在python中使用example:
在python中使用example:
>>> import example
>>> print example.cvar.Foo
3.0
>>> a = example.gcd( 42,23)
>>> print a
1
>>> print example.cvar.Foo
3.0
>>> a = example.gcd( 42,23)
>>> print a
1
- python扩展_swig例子
- 《扩展和嵌入python解释器》1.3 回到例子中
- Python 的性能测试及用C扩展Python的基本例子
- SmartFoxServer Java扩展 例子
- SmartFoxServer Java扩展 例子 .
- jquery扩展例子
- python扩展
- Python 扩展
- 扩展python
- 扩展python
- 《扩展和嵌入python解释器》1.1 一个简单的例子
- python例子
- 第二章-扩展的例子
- 扩展方法的小例子
- fairygui自定义扩展+两个例子
- 利用boost.python 扩展python
- Python 的扩展概述
- Python的C++扩展
- 书到用时方恨少
- tomcat 5.X 的mysql DBCP配置指南及相关问题小结
- 足协开出实德罚单
- 实用EJB开发技巧
- Layout and Style
- python扩展_swig例子
- tomcat4.1下配置servlet
- 我的第一个正式程序
- 搞笑帖
- 利用Reflection API访问类的私有成员
- Welcome.java
- 面向对象设计原则 (摘录)
- SetWindowRedraw(hwndList, FALSE);无闪烁重画
- WinPcap编程渐进教程(中文)