I am trying to load a .so in cppyy, but getting below error.
Is there any way to see what exact error is there, due to which Load() is failing
load_my_lib.py:57: in <module>
cppyy.load_library("mylib.so")
.venv/lib/python3.6/site-packages/cppyy/__init__.py:219: in load_library
sc = gSystem.Load(name)
E cppyy.gbl.std.exception: int CppyyLegacy::TSystem::Load(const char* module, const char* entry = "", CppyyLegacy::Bool_t system = kFALSE) =>
E exception: std::exception
It looks like the loading of the library results in a
std::exception
being thrown that has an empty result out of it'swhat()
.Both the use of
std::exception
rather than one of its derived classes, as well as having no message returned fromwhat()
are a bit of an uncommon use, and I'm not aware of anything in the load library call itself that can cause that. Thus, my best guess would be that it gets thrown during the creation of a global or static variable that lives inmylib.so
.Do you know whether there are any static or global variables in that library? These may also live in a library that
mylib.so
is linked with, and which gets pulled in when loading.Another way that sometimes gets a better diagnostic (although I doubt it in this case, as it doesn't handle C++ exceptions) is to load the library with
ctypes
instead:(
ctypes.CDLL
does not have portable behavior, which is whyload_library
exists, but on most, not all, Linux distros it's a perfectly fine alternative.)