vc6编写python扩展的方法分享

Winona ·
更新时间:2024-09-21
· 581 次阅读

系统环境:VC6 + Python-2.5.4

1、下载Python-2.5.4源码。

2、解压,打开D:\Python-2.5.4\PC\VC6\pcbuild.dsw,编译,D:\Python-2.5.4\PC\VC6\下得到python25.dll、python25_d.dll、python25.lib、python25_d.lib。

3、使用VC6建立一个动态链接库工程,拷贝D:\Python-2.5.4\PC\example_nt\example.c到工程目录下,并添加到工程中。

4、设置工程。
代码如下:
打开tools->options->directories,添加D:\PYTHON-2.5.4\INCLUDE 到 includes files中,添加D:\PYTHON-2.5.4\PC\VC6 到 Library files中。
打开Progect->Settings,将Win32 Debug->Link->Output file name修改为example_d.pyd,将Win32 Release->Link->Output file name修改为example.pyd

5、编译。

6、尝试调用:

代码如下:
D:\MY Project\testpymodule\Release>python
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import example
>>> example.foo()
Hello, world
>>>

您可能感兴趣的文章:Python中内置数据类型list,tuple,dict,set的区别和用法详解Python中内置的NotImplemented类型的用法Python内置数据类型详解python基础教程之基本内置数据类型介绍使用C语言扩展Python程序的简单入门指引详解Python的Django框架中manage命令的使用与扩展Python中扩展包的安装方法详解使用Pyrex来扩展和加速Python程序的教程Python实现扩展内置类型的方法分析



方法 vc6 Python

需要 登录 后方可回复, 如果你还没有账号请 注册新账号