C ++中基本Boost使用的分段错误

时间:2014-02-01 22:15:31

标签: python c++ boost

我有一个非常基本的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

1 个答案:

答案 0 :(得分:4)

谢谢大家的帮助。问题最终导致我编译程序的python库版本与我的PATH上的python版本之间的不一致。