Boost 1.59.0 編譯支持Python3的鏈接庫


官方編譯的Boost中只帶了Python2的鏈接庫,Python3的鏈接庫需要自己特別編譯,官方編譯版下載地址:http://sourceforge.net/projects/boost/files/boost-binaries

1. 將boost_1_59_0源代碼解壓到C:\Boost159

2. 修改user-config.jam

# MSVC configuration
using msvc : 12.0 ;
# Python configuration:
using python : 3.5 : C:\\Anaconda3 : C:\\Anaconda3\\include : C:\\Anaconda3\\libs ;

3. 打開Visual Studio 2013 command prompt,(如果需要32位的鏈接庫,則VS控制台,Python必須為32位;否則全部為64位)

  1)  cd C:\Boost159

  2)  bootstrap

      3)  b2 toolset=msvc-12.0 --build-type=complete --with-python --libdir=C:\Boost159 --abbreviate-paths architecture=x86 address-model=32 install -j4

4. 將C:\Boost159中生成的python3鏈接庫復制到官方編譯版的lib文件夾中。

5. 新建C++工程,復制C:\Boost159\libs\python\example\getting_started2.cpp到工程中,鏈接上boost_python3-vc120-mt-1_59.lib,編譯生成一個dll文件。

6. 將dll文件改成pobject.pyd文件,與boost_python3-vc120-mt-1_59.dll一起拷貝到當前Python工程文件夾,在py文件中直接"import pobject",就能調用C++的函數了。

 

 

Reference:

[1] http://stackoverflow.com/questions/24314644/how-to-get-boost-python-tutorial-example-to-link-with-python3

[2] http://choorucode.com/2014/06/06/how-to-build-boost-for-visual-studio-2013/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM