在Python ctypes中加载共享库期间的分段错误(核心转储)

时间:2015-08-28 00:49:22

标签: python c segmentation-fault ctypes

我正在尝试在Python ctypes中加载C共享库。 (Linux)的

但是在加载共享库时它会生成Segmentation fault (core dumped)

这意味着(如果库的名称是A.so

import ctypes

ctyps.CDLL("A.so")   #it makes Segmentation fault

我想知道的是,如果在加载库时发生Segmentation fault,通常会出现什么问题。

我不明白它是正常编译的,我不会对图书馆中的功能进行任何调用。

在加载库时哪个部分导致此错误?

1 个答案:

答案 0 :(得分:0)

就我而言,template方面存在type C++问题。 例如,我在下面定义了一个template的类。

# a.hpp
template<typename msgType>
class A{
public:
int get(msgType& msg);
...
...
};


#a.cpp
template<typename msgType>
int A<msgType>::get(msgType& msg){
...
}
template int A<std::string>::get(std::string& msg);

然后,如果我将A类与std::string以外的其他类型一起使用,则在加载C ++共享库时会引导Segmentation fault (core dumped)