如何构建python C ++嵌入的boost示例

时间:2015-08-13 14:55:21

标签: python c++ boost embedding

Atm我需要包装一个C ++库,以便在python代码中使用。为此,我似乎最好使用boost python扩展/包装器。但是现在我在编译文档中显示的每个示例时都存在问题。我能够使它运行python27和boost_1_55的组合,但任何事情都没有(python34 boost_1_58)似乎不起作用。以下是构建2个基本示例的错误消息(我正在运行windows7 64bit):

一般测试

C:\boost_1_59_0_b1\libs\python\example\quickstart>C:\boost_1_59_0_b1\bjam.exe toolset=msvc-12.0 --verbose-test test_ext
Performing configuration checks

- 32-bit                   : yes (cached)
- arm                      : no  (cached)
- mips1                    : no  (cached)
- power                    : no  (cached)
- sparc                    : no  (cached)
- x86                      : yes (cached)
...patience...
...patience...
...found 1923 targets...
...updating 4 targets...
msvc.link.dll bin\msvc-12.0\debug\threading-multi\extending.pyd
Creating library bin\msvc-12.0\debug\threading-multi\extending.pdb and object
bin\msvc-12.0\debug\threading-multi\extending.exp
LINK : fatal error LNK1207: incompatible PDB format in 'C:\boost_1_59_0_b1\libs\
python\example\quickstart\bin\msvc-12.0\debug\threading-multi\extending.pdb'; delete and rebuild

    call "C:\Users\XY\AppData\Local\Temp\b2_msvc_12.0_vcvarsall_x86.cmd" >nul
link /NOLOGO /INCREMENTAL:NO /DLL /NOENTRY /DEBUG /MACHINE:X86 /MANIFEST /subsystem:console /out:"bin\msvc-12.0\debug\threading-multi\extending.pyd" /IMPLIB:"bi
n\msvc-12.0\debug\threading-multi\extending.pdb" /LIBPATH:"C:\Python34\libs"   @
"bin\msvc-12.0\debug\threading-multi\extending.pyd.rsp"
    if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL%

...failed msvc.link.dll bin\msvc-12.0\debug\threading-multi\extending.pyd     bin\msvc-12.0\debug\threading-multi\extending.pdb...
...removing bin\msvc-12.0\debug\threading-multi\extending.pdb
...skipped <pbin\test_ext.test\msvc-12.0\debug\threading-multi>test_ext for lack
of <pbin\msvc-12.0\debug\threading-multi>extending.pyd...
...failed updating 2 targets...
...skipped 2 targets...

嵌入示例:

C:\boost_1_59_0_b1\libs\python\example\quickstart>C:\boost_1_59_0_b1\bjam.exe toolset=msvc-12.0 --verbose-test embedding
Performing configuration checks

- 32-bit                   : yes (cached)
- arm                      : no  (cached)
- mips1                    : no  (cached)
- power                    : no  (cached)
- sparc                    : no  (cached)
- x86                      : yes (cached)
...patience...
...patience...
...found 1992 targets...
...updating 3 targets...
compile-c-c++ bin\msvc-12.0\debug\threading-multi\embedding.obj
embedding.cpp
embedding.cpp(56) : error C2065: 'initembedded_hello' : undeclared identifier

call "C:\Users\XY\AppData\Local\Temp\b2_msvc_12.0_vcvarsall_x86.cm
d" >nul
cl /Zm800 -nologo @"bin\msvc-12.0\debug\threading-multi\embedding.obj.rsp"

...failed compile-c-c++ bin\msvc-12.0\debug\threading-multi\embedding.obj...
...skipped <pbin\msvc-12.0\debug\threading-multi>embedding.exe for lack of <pbin
\msvc-12.0\debug\threading-multi>embedding.obj...
...skipped <pbin\msvc-12.0\debug\threading-multi>embedding.pdb for lack of <pbin
\msvc-12.0\debug\threading-multi>embedding.obj...
...failed updating 1 target...
...skipped 2 targets...

1 个答案:

答案 0 :(得分:0)

我在boost-python教程中遇到了类似的问题。我认为原因是我没有python库的调试版本。为了解决这个问题,我将属性variant=release添加到了我的b2调用中。这解决了我的不兼容的pdb文件的问题,虽然更好的选择是获得python的调试版本。不幸的是,它只会让我进一步构建错误!