I was provided with a c library wave.so, with a function interfaced defined, I follow the guide here
https://stackoverflow.com/a/5868051/2789784
and it works. However, when I made the script to be a file MyModule.py, and try to import by
import MyModule
Then it gives me this error.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dynamic module does not define init function (initwave)
Why does this happen? How should I fix it?
FIXED: so I have both MyModule.py and MyModule.so at the same folder, python tried to load MyModule.so instead of MyModule.py, and of course he cannot be successful, change the name of MyModule.py to wave.py and
import wave
solves the problem. So basically if you just want to call some c++ library function, you really just need a python script wrapper and that's it, no c-programming. And I can use my c++ shared library for other application too.