How to load .so file?
Closed this issue · 2 comments
Hi, I can use the module when directly import pbcvt
but how can I use it by something like this
from ctypes import cdll
pbcvt = cdll.LoadLibrary('./pbcvt.cpython-36m-x86_64-linux-gnu.so')
pbcvt.dot(a, b)
When I do this, it raise error:
AttributeError: ./pbcvt.cpython-36m-x86_64-linux-gnu.so: undefined symbol: dot
Thank you!
@lan2720 I'm not familiar with loading C / C++ python extension libraries via the cdll module. Are you able to load other libraries with the "./" in front of the name? Can you give me an example of the command you use when loading libraries like this works for you?
@lan2720 , I was actually able to successfully load similar C++ extensions using
cpp_extension =
importlib.machinery.ExtensionFileLoader(
"<path_to_extension>").load_module()
in Python 3. "load_module" is deprecated but for now seems to be working. I haven't tried with cdll
, hopefully you got it to work. I'm closing this since I haven't heard from you in awhile, feel free to reopen if you're still having trouble and are going to answer my questions.