构建Boost Python调试

时间:2012-12-23 08:19:40

标签: python boost python-3.x boost-python python-embedding

我绝对不是bjam专家,所以请原谅我的无知,如果它真的很蠢。

我正在尝试使用this tutorial构建debugboost::python

我在我的文件夹Python 3.3.0中构建了C:\Development\Python-3.3.0。构建有效,.lib.dll.exe都存在于PCBuild文件夹中。我测试了解释器,它运行正常。

我使用以下命令行:

bjam --user-config=user-config.jam --with-python python-debugging=on threading=multi variant=debug link=shared stage

我的问题来自user-config.jam。我尝试使用以下内容遵循本教程的规范:

using python : 3.3 : C:\\Development\\Python-3.3.0\\PCBuild\\python_d.exe
    : C:\\Development\\Python-3.3.0\\Include C:\\Development\\Python-3.3.0\\PC
    : C:\\Development\\Python-3.3.0\\PCBuild
    : <python-debugging>on ;

但链接失败......出于某种原因,它似乎没有发现我希望它使用3.3,这里是输出日志的一部分:

...updating 10 targets...
msvc.link.dll bin.v2\libs\python\build\msvc-11.0\debug\python-debugging-on\threa
ding-multi\boost_python-vc110-mt-gyd-1_52.dll
LINK : fatal error LNK1104: cannot open file 'python26_d.lib'

        call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.b
at" x86 >nul
link /NOLOGO /INCREMENTAL:NO /DLL /DEBUG /MACHINE:X86 /subsystem:console /out:"b
in.v2\libs\python\build\msvc-11.0\debug\python-debugging-on\threading-multi\boos
t_python-vc110-mt-gyd-1_52.dll" /IMPLIB:"bin.v2\libs\python\build\msvc-11.0\debu
g\python-debugging-on\threading-multi\boost_python-vc110-mt-gyd-1_52.lib" /LIBPA
TH:"C:\Development\Python-3.3.0\PCBuild"   @"bin.v2\libs\python\build\msvc-11.0\
debug\python-debugging-on\threading-multi\boost_python-vc110-mt-gyd-1_52.dll.rsp
"

我尝试修改user-config.jam。起初,我没有逃脱\,令人惊讶的是,它检测到我想构建3.3但/LIBPATH错误(没有反斜杠):

...updating 10 targets...
msvc.link.dll bin.v2\libs\python\build\msvc-11.0\debug\python-debugging-on\threa
ding-multi\boost_python-vc110-mt-gyd-1_52.dll
LINK : fatal error LNK1181: cannot open input file 'python33_d.lib'

        call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.b
at" x86 >nul
link /NOLOGO /INCREMENTAL:NO /DLL /DEBUG /MACHINE:X86 /subsystem:console /out:"b
in.v2\libs\python\build\msvc-11.0\debug\python-debugging-on\threading-multi\boos
t_python-vc110-mt-gyd-1_52.dll" /IMPLIB:"bin.v2\libs\python\build\msvc-11.0\debu
g\python-debugging-on\threading-multi\boost_python-vc110-mt-gyd-1_52.lib" /LIBPA
TH:"C:DevelopmentPython-3.3.0PCBuild"   @"bin.v2\libs\python\build\msvc-11.0\deb
ug\python-debugging-on\threading-multi\boost_python-vc110-mt-gyd-1_52.dll.rsp"

正如您所看到的,它正在寻找python33_d.lib,这是所需要的,但/LIBPATH不包含\。我还尝试使用/进行替换,然后再次尝试链接python26_d.lib

如果它有用,我卸载了以前安装的任何Python版本。

如何正确地使我的jam文件需要版本3.3并提供正确的路径?

编辑:更多地播放,我删除了;之前的“空格”...正好这样做才能找到合适的版本3.3,但是它试图将发布版本与相对libs文件夹链接起来...最糟糕的情况我不介意将库从PCBuild复制到libs

using python : 3.3 : C:\\Development\\Python-3.3.0\\PCBuild\\python_d.exe
    : C:\\Development\\Python-3.3.0\\Include C:\\Development\\Python-3.3.0\\PC
    : C:\\Development\\Python-3.3.0\\PCBuild
    : <python-debugging>on;

有趣的是,它与我想要达到的最接近,但它输出

C:\Development\boost_1_52_0\boost_1_52_0\user-config.jam:4: syntax error at EOF

jam解析器似乎很弱......任何提示或提示都会有所帮助

编辑2:尝试简化问题,我将user-config.jam更改为仅包含:

using python : 3.3 ;

并使用以下命令行:

bjam --user-config=user-config.jam --with-python threading=multi variant=release link=shared stage

正如所料,它无法找到.lib

...updating 4 targets...
msvc.link.dll bin.v2\libs\python\build\msvc-11.0\release\threading-multi\boost_p
ython3-vc110-mt-1_52.dll
LINK : fatal error LNK1181: cannot open input file 'python33.lib'

        call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.b
at" x86 >nul
link /NOLOGO /INCREMENTAL:NO /DLL /MACHINE:X86 /subsystem:console /out:"bin.v2\l
ibs\python\build\msvc-11.0\release\threading-multi\boost_python3-vc110-mt-1_52.d
ll" /IMPLIB:"bin.v2\libs\python\build\msvc-11.0\release\threading-multi\boost_py
thon3-vc110-mt-1_52.lib" /LIBPATH:"C:\Development\Python-3.3.0\libs"   @"bin.v2\
libs\python\build\msvc-11.0\release\threading-multi\boost_python3-vc110-mt-1_52.
dll.rsp"

所以我决定将我的PCBuild文件夹克隆到libs,以便我可以访问我构建的所有库...但是这样做之后,不更改.jam或命令line ...它现在正在寻找Python 2.6?!?

...updating 4 targets...
msvc.link.dll bin.v2\libs\python\build\msvc-11.0\release\threading-multi\boost_p
ython3-vc110-mt-1_52.dll
LINK : fatal error LNK1104: cannot open file 'python26.lib'

        call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.b
at" x86 >nul
link /NOLOGO /INCREMENTAL:NO /DLL /MACHINE:X86 /subsystem:console /out:"bin.v2\l
ibs\python\build\msvc-11.0\release\threading-multi\boost_python3-vc110-mt-1_52.d
ll" /IMPLIB:"bin.v2\libs\python\build\msvc-11.0\release\threading-multi\boost_py
thon3-vc110-mt-1_52.lib" /LIBPATH:"C:\Development\Python-3.3.0\libs"   @"bin.v2\
libs\python\build\msvc-11.0\release\threading-multi\boost_python3-vc110-mt-1_52.
dll.rsp"

我挖的越多,我就越困惑......还有一个失败了LNK1104而另一个失败了LNK1181 ......

1 个答案:

答案 0 :(得分:3)

好吧,我最终决定从bjam剥离所有可能的参数并从头开始构建。我终于使用此命令行bjam来构建每个目标:

 bjam --user-config=user-config.jam --with-python

user-config.jam仅包含以下内容:

using python : 3.3 : C:\\Development\\Python-3.3.0\\PCBuild\\python.exe
    : C:\\Development\\Python-3.3.0\\Include C:\\Development\\Python-3.3.0\\PC
    : C:\\Development\\Python-3.3.0\\PCBuild : ;

似乎现在正常工作。

由于