ImportError: dynamic module does not define init function(initmymodule)

Michael Hudson mwh at python.net
Thu Aug 12 07:08:59 EDT 2004


balaji at email.arizona.edu (Balaji) writes:

> I have an c++ header file.
> 
> //some_class.h
> 
> #ifndef _SOME_CLASS_H_
> #define _SOME_CLASS_H_
> 
> class SomeClass
> {
> public:
> 	int sqr(int a);
> };
> #endif //_SOME_CLASS_H_
> 
> and I have an definition file some_class.C
> 
> //some_class.C
> 
> #include "some_class.h"
> 
> 
> int SomeClass::sqr(int a){
> 	return a*a;
> }
> And I have an interface file
> %module mytest
> %{
> #include "some_class.h"
> }
> %include "some_class.h"
> 
> My question is when I try to import mytest in python it does import it
> but I'm not able to access the SomeClass..

Does SWIG expect to be compiled using a C++ compiler (I don't know).
I suspect you're falling victim to C++ name mangling, but I don't know
enough about SWIG to tell you what to try instead.

Cheers,
mwh

-- 
  Programming languages should be designed not by piling feature on
  top of feature, but by removing the weaknesses and restrictions
  that make the additional features appear necessary.
               -- Revised(5) Report on the Algorithmic Language Scheme



More information about the Python-list mailing list