467,223 Members | 1,400 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,223 developers. It's quick & easy.

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

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
Jul 18 '05 #1
  • viewed: 3308
Share:
1 Reply
ba****@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
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by mg | last post: by
1 post views Thread by Torsten Mohr | last post: by
6 posts views Thread by mg | last post: by
3 posts views Thread by kman3048 | last post: by
2 posts views Thread by Andras Balogh | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.