在 Python ctypes 中加载共享库期间出现分段错误(核心已转储)
Segmentation fault (core dumped) during loading shared library in Python ctypes
我正在尝试在 Python ctypes 中加载 C 共享库。 (linux)
但是在加载共享库的过程中Segmentation fault (core dumped)
。
这意味着(如果库的名称是A.so
)
import ctypes
ctyps.CDLL("A.so") #it makes Segmentation fault
我想知道的是如果在加载库的过程中发生Segmentation fault
通常是什么问题。
我不明白它是正常编译的,我没有调用库中的函数。
加载库时哪个部分导致这个错误?
就我而言,这是 template
type
方面的问题 C++
。
例如,我定义了一个 class 和 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
class 和 std::string
以外的其他类型,它会在加载 C++ 共享库时导致 Segmentation fault (core dumped)
。
我正在尝试在 Python ctypes 中加载 C 共享库。 (linux)
但是在加载共享库的过程中Segmentation fault (core dumped)
。
这意味着(如果库的名称是A.so
)
import ctypes
ctyps.CDLL("A.so") #it makes Segmentation fault
我想知道的是如果在加载库的过程中发生Segmentation fault
通常是什么问题。
我不明白它是正常编译的,我没有调用库中的函数。
加载库时哪个部分导致这个错误?
就我而言,这是 template
type
方面的问题 C++
。
例如,我定义了一个 class 和 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
class 和 std::string
以外的其他类型,它会在加载 C++ 共享库时导致 Segmentation fault (core dumped)
。