SWIG problem with python
I've made a couple of c functions in a dll build with vc++ 6.0. I've used swig to expose it to python. Now, when I try to import the module in python I get the error message:
>>> import swigc1
Traceback (most recent call last):
File "<pyshell#0>", line 1, in -toplevel-
import swigc1
ImportError: dynamic module does not define init function (initswigc1)
Can anybody tell me what is wrong?
Thanks in advance,
Per Rasmussen.
Every Ptython extension module must export a function named in the form of init<module name>. I've never used SWIG for generating Pyhon extensions, but I assume it should be creating that function for you. Look in the generated source and see if the function exists and was properly exported (__declspec(dllexport)).
Another problem could be calling convention. If your module is C++ rather than C then the initswigc1 function must be declared as:
extern "C" __declspec(dllexport) initswigc1()
{
...
}
Personally, I have found that implementing Python bindings by hand is much more straightforward than messing with tools such as SWIG or Boost::Python. It's dead simple, really. SWIG can sometimes be a PITA.
Another problem could be calling convention. If your module is C++ rather than C then the initswigc1 function must be declared as:
extern "C" __declspec(dllexport) initswigc1()
{
...
}
Personally, I have found that implementing Python bindings by hand is much more straightforward than messing with tools such as SWIG or Boost::Python. It's dead simple, really. SWIG can sometimes be a PITA.
--- Official D Blog | Learning D | The One With D | D Bits
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement