2013-08-28 41 views
0

我是python编程的新手,我正在寻找一些C++ dll到python中。我发现boost.python是这个问题最常见的答案,并且试图用boost.python包中包含的一个简单的'hello world'应用程序来测试它。在http://www.boost.org/doc/libs/1_54_0/libs/python/doc/tutorial/doc/html/python/hello.htmlBoost.Python在编译时跳过dll

继教程中,我使用Microsoft Visual Studio 10.0运行Windows 7。

我的Python目录是'C:\Python27',升压是'C:\Boost\boost_1_54_0'

我有用户config.jam中的文件设置为using msvc : 10.0 ;using python : 2.7 : C:\\Python27 ;

当我调用的bjam我得到以下..

...failed msvc.link.dll C:\Boost\boost_1_54_0\bin.v2\libs\python\build\msvc-10.0\debug\boost_python-vc100-gd-1_54.dll C:\Boost\boost_1_54_0\bin.v2\libs\python\build\msvc-10.0\debug\boost_python-vc100-gd-1_54.lib C:\Boost\boost_1_54_0\bin.v2\libs\python\build\msvc-10.0\debug\boost_python-vc100-gd-1_54.pdb... 
...removing C:\Boost\boost_1_54_0\bin.v2\libs\python\build\msvc-10.0\debug\boost_python-vc100-gd-1_54.lib 
...removing C:\Boost\boost_1_54_0\bin.v2\libs\python\build\msvc-10.0\debug\boost_python-vc100-gd-1_54.pdb 
...skipped <pbin\msvc-10.0\debug>hello_ext.pyd for lack of <pC:\Boost\boost_1_54_0\bin.v2\libs\python\build\msvc-10.0\debug>boost_python-vc100-gd-1_54.lib... 
...skipped <pbin\msvc-10.0\debug>hello_ext.lib for lack of <pC:\Boost\boost_1_54_0\bin.v2\libs\python\build\msvc-10.0\debug>boost_python-vc100-gd-1_54.lib... 
...skipped <pbin\msvc-10.0\debug>hello_ext.pdb for lack of <pC:\Boost\boost_1_54_0\bin.v2\libs\python\build\msvc-10.0\debug>boost_python-vc100-gd-1_54.lib... 
...skipped <p.>boost_python-vc100-gd-1_54.dll for lack of <pC:\Boost\boost_1_54_0\bin.v2\libs\python\build\msvc-10.0\debug>boost_python-vc100-gd-1_54.dll... 
...skipped <p.>hello_ext.pyd for lack of <pbin\msvc-10.0\debug>hello_ext.pyd... 
...skipped <pbin\hello.test\msvc-10.0\debug>hello for lack of <pbin\msvc-10.0\debug>hello_ext.pyd... 
...failed updating 3 targets... 
...skipped 7 targets... 

所有创建的是.obj文件:

C:\Boost\boost_1_54_0\libs\python\example\tutorial\bin\msvc-10.0\debug

从我的基本知识有限,似乎是在刚刚编译之前被删除依赖的文件。我长期努力寻找解决方案,但无济于事。这感觉就像我错过了一些非常基本的东西。

谢谢。

编辑:更新到Python 3.3似乎让我更接近。它不再从bin.v2中删除这两个文件,但它仍然不编译.dll或.pyb文件。

PS C:\Boost\boost_1_54_0\libs\python\example\tutorial> .\bjam 
...patience... 
...patience... 
...found 1681 targets... 
...updating 7 targets... 
msvc.link.dll bin\msvc-10.0\debug\hello_ext.pyd 
LINK : fatal error LNK1104: cannot open file 'boost_python-vc100-mt-gd-1_54.lib' 

    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:\Python33\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... 
...skipped <p.>hello_ext.pyd for lack of <pbin\msvc-10.0\debug>hello_ext.pyd... 
...failed updating 3 targets... 
...skipped 1 target... 
+0

解决:首先,我通过运行'B2工具集= MSVC-10.0 --with-蟒--user-配置=用户config.jam中--build型=完全stage'在'C重建的Boost.Python:\ Boost \ boost_1_54_0'然后我将'boost_python-vc100-mt-gd-1_54.lib'文件复制到tutorial文件夹中。不知道这是最好的解决方案,但它似乎现在正在工作。 – gargarvin

回答

2

解决:首先,我通过运行在C:\Boost\boost_1_54_0b2 toolset=msvc-10.0 --with-python --user-config=user-config.jam --build-type=complete stage重建Boost.Python的话,我复制boost_python-vc100-mt-gd-1_54.lib文件到教程文件夹。不知道这是最好的解决方案,但它似乎现在正在工作。

+0

您是否将'C:\ Boost \ boost_1_54_0'文件夹添加为链接器的include目录以查找'boost_python-vc100-mt-gd-1_54.lib'?当我在Windows上编译boost.python应用程序时,我不需要将boost_python * .lib移动到本地目录中。 – 2013-09-04 06:17:34

0

我建议提在配置文件中的Python安装路径:

using python : 2.7 : C:\Python27\; 

你有没有cd到同一个目录下Jamroot中和HELLO.CPP所在?

+0

对不起,我在用户配置中也这样做了,是的,我和jamroot和hello.cpp是同一个目录。 在该“bin文件夹它创建包含任何与“MSVC-10.0”文件夹“hello.test中”文件夹包含“hello.obj”,“hello.obj.rsp”和“hello_ext.pyd.rsp” – gargarvin

+0

它似乎最后不喜欢'toolset ',但我可以在调用bjam时添加该参数否?否则我仍然越来越...失败更新3个目标...并且...跳过了1个目标... 谢谢 – gargarvin

+0

编辑:' msvc'将运行但仍然没有骰子。 – gargarvin