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

B

Balaji

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..

Can anyone help..

Balaji



When I try to conver this into python module by using SWIG I manage to
import
 
M

Michael Hudson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top