boost Python 編譯通過記錄

首先,編譯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!'                                                                                                                              
             >>                                                                                                                                                 
萬事大吉。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章