I am trying to load C shared library in Python ctypes. (linux)
But It makes a Segmentation fault (core dumped)
during loading the shared library.
That means (if the name of library is A.so
)
import ctypes
ctyps.CDLL("A.so") #it makes Segmentation fault
What I want to know is usually what is a problem if Segmentation fault
happens during loading the library.
I don't understand it is compiled normally and I don't any call to functions in the library.
Which part lead this error during loading the library?
In my case, that was template
type
problem in C++
side. For example, I defined a class with template
like below.
# 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);
And then if I use A
class with other types other than std::string
somewhere, it leads Segmentation fault (core dumped)
while loading the C++ shared library.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.