How are symbols contained in the libpythonX.X linked to numpy extension dynamic libraries? How are symbols contained in the libpythonX.X linked to numpy extension dynamic libraries? numpy numpy

How are symbols contained in the libpythonX.X linked to numpy extension dynamic libraries?


multiarray.cpython-35m-x86_64-linux-gnu.so was built without explicit link with python's dynamic library, that why you couldn't see the libpythonx.x.x by using ldd.

If you use nm to check this so, you will see the symbol PyExc_UserWarning is undefined.

So when numpy load this so by using dlopen, it will try to resolve this undefined symbol. I didn't find any document explain the rule how libdl.so resolve the undefined symbol. But according to my test, when you try to open a shared library use dlopen with flag RTLD_NOW, it will search dependent shared library of main program for the undefined symbol.

That could explain why python could use it without error, because python binary is linked with libpython.x.x.so.