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
>>>
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com