作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
Atm 我需要包装一个 C++ 库以便在 python 代码中使用。为此,我认为最好使用 boost python 扩展/包装器。但是现在我在编译文档中显示的每个示例时一直遇到问题。我能够让它运行 python27 和 boost_1_55 的组合,但任何东西(python34 boost_1_58)似乎都不起作用。以下是构建 2 个基本示例的错误消息(我正在运行 windows7 64 位):
一般测试
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...
最佳答案
我在 boost-python 教程中遇到了类似的问题。我认为原因是我没有 python 库的调试版本。为了解决这个问题,我将属性 variant=release
添加到我对 b2 的调用中。这解决了我的不兼容 pdb 文件的问题,尽管更好的选择是获取 python 的调试版本。不幸的是,它只会让我进一步构建错误!
关于python - 如何为 python C++ 嵌入构建 boost 示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31991749/
我是一名优秀的程序员,十分优秀!