我正在尝试在Python ctypes中加载C共享库。 (Linux)的
但是在加载共享库时它会生成Segmentation fault (core dumped)
。
这意味着(如果库的名称是A.so
)
import ctypes
ctyps.CDLL("A.so") #it makes Segmentation fault
我想知道的是,如果在加载库时发生Segmentation fault
,通常会出现什么问题。
我不明白它是正常编译的,我不会对图书馆中的功能进行任何调用。
在加载库时哪个部分导致此错误?
答案 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)
。