在编译时跳过Boost.Python dll

时间:2013-08-28 18:54:47

标签: c++ python visual-studio-2010 boost boost-python

我是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.html

上的教程进行操作

我正在使用Microsoft Visual Studio 10.0运行Windows 7。

我的python目录是'C:\Python27',Boost是'C:\Boost\boost_1_54_0'

我已将user-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...

2 个答案:

答案 0 :(得分:2)

已解决:首先我在b2 toolset=msvc-10.0 --with-python --user-config=user-config.jam --build-type=complete stage中运行C:\Boost\boost_1_54_0重建了boost.python,然后将boost_python-vc100-mt-gd-1_54.lib文件复制到教程文件夹中。不确定这是最好的解决方案,但它现在似乎正在发挥作用。

答案 1 :(得分:0)

我建议在配置文件中提及python安装路径:

using python : 2.7 : C:\Python27\;

你有没有进入jamroot和hello.cpp所在的同一目录?