gpt4 book ai didi

python - C++ 中基本 Boost 用法的段错误

转载 作者:搜寻专家 更新时间:2023-10-31 01:06:06 24 4
gpt4 key购买 nike

我有一个非常基本的 C++ 程序,其最终目标是创建一个返回 Python 元组的函数。我已经将它剥离了这些最小的行:

#include <stdio.h>
#include <boost/python.hpp>
#include <boost/tuple/tuple.hpp>

int main(){
Py_Initialize(); // initialize the python module
boost::python::list test_list;
boost::python::tuple test = boost::python::tuple(test_list);
return 1;
}

然而,在线:

boost::python::tuple test = boost::python::tuple(test_list);

我最终总是得到:

Segmentation fault: 11

我使用的是 Mac OS X 10.9.1 和 Boost 1.55。任何清晰度将不胜感激。

这是崩溃报告:

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000018

VM Regions Near 0x18:
-->
__TEXT 000000010bf76000-000000010bf78000 [ 8K] r-x/rwx SM=COW /Users/USER/*/*.out

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 org.python.python 0x000000010c1f4f40 PyObject_Call + 51
1 org.python.python 0x000000010c1f5101 0x10c1eb000 + 41217
2 org.python.python 0x000000010c1f508f PyObject_CallFunction + 187
3 libboost_python.dylib 0x000000010bf8a282 boost::python::detail::tuple_base::tuple_base(boost::python::api::object const&) + 34 (tuple.cpp:13)
4 a.out 0x000000010bf77885 boost::python::tuple::tuple<boost::python::list>(boost::python::list const&) + 53 (tuple.hpp:41)
5 a.out 0x000000010bf777dd boost::python::tuple::tuple<boost::python::list>(boost::python::list const&) + 29 (tuple.hpp:42)
6 a.out 0x000000010bf77431 main + 49 (camera_hello_world.cpp:8)
7 libdyld.dylib 0x00007fff8ead25fd start + 1

Thread 0 crashed with X86 Thread State (64-bit):
rax: 0x000000010c2f0328 rbx: 0x000000010c4f6050 rcx: 0x0000000000000000 rdx: 0x0000000000000000
rdi: 0x000000010c2efb30 rsi: 0x000000010c4f6050 rbp: 0x00007fff53c899d0 rsp: 0x00007fff53c899a0
r8: 0x0000000000000000 r9: 0x0800000000000100 r10: 0x00007fff8ed8e83f r11: 0x00007fff825ec980
r12: 0x000000010c2efb30 r13: 0x000000010c2360c7 r14: 0x000000010c31c2a0 r15: 0x000000010c4f6050
rip: 0x000000010c1f4f40 rfl: 0x0000000000010202 cr2: 0x0000000000000018

最佳答案

谢谢大家的帮助。问题最终是我编译程序时使用的 python 库版本与我的 PATH 上的 python 版本不一致。

关于python - C++ 中基本 Boost 用法的段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21504362/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com