boost 1.32 - Python 编译通过记录

来源:互联网 发布:磁力搜索引擎软件 编辑:程序博客网 时间:2024/06/05 05:08
首先,编译boost_python.dll:
       在目录boost/boost_1_32_0/libs/python/build/VisualStudio下,有vc的工程文件boost_python.dsw,我是用VC6编译的,这个文件刚好用:-)打开它。编译release还是debug随便,在tools->option->directories中,添加include file,D:/BOOST/BOOST_1_32_0C:/TOOLS/PYTHON/INCLUDE<pyconfig.h>文件路径),添加Library files,C:/TOOLS/PYTHON/LIBS(包涵python24.lib),然后就可以编译通过了,顺利!

接下来,编译教程中的hello.cpp,就是
             >>import hello                                             
             >>hello.greet()                                            
             'Hello, world!'                                               
的那个文件,要使用bjam,boost32里面那个就好用,至于Jamfile用原配的吧
需要注意的是:

          set PYTHON_ROOT=c:/dev/tools/python 
    
set PYTHON_VERSION
=2.2                       

这两句话一定要执行一下,尤其PYTHON_VERSION,一定要是2.2,千万别耍小聪明,弄个2.3,2.4什么的,不然自讨苦吃,然后开始编译(使用vc6)
      bjam -sTOOLS=msvc                  
很快就能得到
hello.pyd,表示编译成功!

最后,把hello.pyd和boost_python.dll拷贝到同一个目录,如:D:/python/boost下,来到命令行运行:

            D:/python/boost/python                                                                                                            
            Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32            
            Type "help", "copyright", "credits" or "license" for more information.                               
            >>import hello                                                                                                                            
             >>hello.greet()                                                                                                                           
             'Hello, world!'                                                                                                                              
             >>                                                                                                                                                 
万事大吉。
原创粉丝点击