我想用boost.python
與python 3.2+
(優選爲3.4)和Visual Studio 2010如何獲取boost.python教程示例以鏈接到Python3?
當我試圖讓反對任何Python3的libs\python\example\tutorial
例子(我已經測試過3.0,3.2和3.4),它不鏈接(見下面)。當我把它與2.7連接起來時,它就可以工作
我在兩次嘗試之間做出的唯一更改是在我的主目錄中更新user-config.jam
。
所以工作時user-config.jam
是:
# MSVC configuration
using msvc : 10.0 ;
# Python configuration:
using python : 2.7 : C:\\Python27 : C:\\Python27\\include : C:\\Python27\\libs ;
當我運行bjam
我得到:
C:\Boost\boost_1_55_0\libs\python\example\tutorial>bjam
link.jam: No such file or directory
...patience...
...patience...
...found 1678 targets...
...updating 8 targets...
compile-c-c++ bin\msvc-10.0\debug\hello.obj
hello.cpp
msvc.link.dll bin\msvc-10.0\debug\hello_ext.pyd
Creating library bin\msvc-10.0\debug\hello_ext.lib and object bin\msvc-10.0\debug\hello_ext.exp
msvc.manifest.dll bin\msvc-10.0\debug\hello_ext.pyd
common.copy boost_python-vc100-gd-1_55.dll
..\..\..\..\bin.v2\libs\python\build\msvc-10.0\debug\boost_python-vc100-gd-1_55.dll
1 file(s) copied.
common.copy hello_ext.pyd
bin\msvc-10.0\debug\hello_ext.pyd
1 file(s) copied.
capture-output bin\hello.test\msvc-10.0\debug\hello
1 file(s) copied.
**passed** bin\hello.test\msvc-10.0\debug\hello.test
...updated 8 targets...
如果我改變user-config.jam
到:
# MSVC configuration
using msvc : 10.0 ;
# Python configuration:
using python : 3.4 : C:\\Python34 : C:\\Python34\\include : C:\\Python34\\libs ;
,並bjam clean
,然後bjam
我得到:
C:\Boost\boost_1_55_0\libs\python\example\tutorial>bjam
link.jam: No such file or directory
...patience...
...patience...
...found 1685 targets...
...updating 9 targets...
compile-c-c++ bin\msvc-10.0\debug\hello.obj
hello.cpp
msvc.link.dll bin\msvc-10.0\debug\hello_ext.pyd
Creating library bin\msvc-10.0\debug\hello_ext.lib and object bin\msvc-10.0\debug\hello_ext.exp
hello.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) struct _object * __cdecl boost::python::detail::init_module(struct PyModuleDef &,void (__cdecl*)(void))" ([email protected]@[email protected]@@YAPAU[email protected]@[email protected]@[email protected]) referenced in function _PyInit_hello_ext
bin\msvc-10.0\debug\hello_ext.pyd : fatal error LNK1120: 1 unresolved externals
call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86 >nul
link /NOLOGO /INCREMENTAL:NO /DLL /DEBUG /MACHINE:X86 /MANIFEST /subsystem:console /out:"bin\msvc-10.0\debug\hello_ext.pyd" /IMPLIB:"bin\msvc-10.0\debug\hello_ext.lib" /LIBPATH:"C:\Python34\libs" @"bin\msvc-10.0\debug\hello_ext.pyd.rsp"
if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL%
...failed msvc.link.dll bin\msvc-10.0\debug\hello_ext.pyd bin\msvc-10.0\debug\hello_ext.lib bin\msvc-10.0\debug\hello_ext.pdb bin\msvc-10.0\debug\hello_ext.pdb...
...removing bin\msvc-10.0\debug\hello_ext.lib
...removing bin\msvc-10.0\debug\hello_ext.pdb
common.copy boost_python-vc100-gd-1_55.dll
..\..\..\..\bin.v2\libs\python\build\msvc-10.0\debug\boost_python-vc100-gd-1_55.dll
1 file(s) copied.
...skipped <p.>hello_ext.pyd for lack of <pbin\msvc-10.0\debug>hello_ext.pyd...
...failed updating 3 targets...
...skipped 1 target...
...updated 2 targets...
尋找網上我發現一對夫婦此錯誤的引用,但沒有解決辦法... 這裏是最好的鏈接:
http://lists.boost.org/boost-build/2011/06/25147.php
我所看到的很多人在談論使用Python3和boost.python,所以我必須錯過一些東西...... 我是否需要專門爲Python 3編譯boost?
幫助?
/Robert
好的,我在這裏提出了一些問答。希望給你一些指點,至少我們現在正在評論能力!別客氣!我有興趣閱讀更多有用的問題或答案,寫在你身上! –