2014-09-03 39 views
2

我解析了一个C++项目,编译为python的library.so。所以我不能在Qt Creator IDE中进行调试。为此,我创建单独的项目具有可执行主()如何创建空的工具boost :: python :: dict?

int main() 
{ 
    boost::python::dict whiteList; 
    whiteList.has_key("blablabla"); 
    ... 
    return 0; 
} 

在释放模式程序编译和运行不正常。但在调试模式程序has_key()方法失败,错误窗口:

The inferior stopped because it received a signal from the Operating System. 
Signal name : SIGSEGV 
Signal meaning : Segmentation fault 

可能的问题是:如何正确地创建和使用boost::python::dict纯粹的内部C++程序,而不涉及python脚本?

回答

2

每当你使用Python C API或Boost Python中,你必须初始化的Python:

Py_Initialize(); 

是添加到您的main()等的顶部瞧。