SWIG help

Can anyone help me with swig i’m stuck!
My C++

#ifndef _SOME_CLASS_H_
#define _SOME_CLASS_H_

class SomeClass
        int     mValA;
        int     mValB;
        SomeClass() { }
        SomeClass(int a, int b) { }
        virtual ~SomeClass() { }
        void MethodA(){ }
        void MethodB(int a = 5)
           mValB= b;
        int GetValA()
           return mValA;

#endif  // _SOME_CLASS_H_

The interface file:

%module mymodule

#include "some_class.h"

class SomeClass
        virtual ~SomeClass();
        void MethodA();
        void MethodB(int a = 5);
        int GetValA();

i run

swig.exe -c++ -python -o mymodule_wrap.cpp mymodule.i

and build a dll with MSVC7
renamed it to _mymodule.dll
when i try to import mymodule i get this:

>>> import mymodule
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "mymodule.py", line 5, in ?
    import _mymodule
ImportError: No such file or directory

Is there anyone who uses SWIG.
Or is it better to use interrogate? If yes how to use it?

Thanks Martin

I can not help much with SWIG and c++ classes except to say that if I remember right it really does not have a transform for C++ classes to python objects. It can pass around pointer to c++ objects but not sure were they currently stand here. This may have changed please let us know if you find otherwise.


If what you want to do is bind a little c/c++ code to python and you are starting from scratch on the code. Hand type it as native python C. Start with the samples in there manual and you will be flying really fast. You have much more flexibility and can do tons of things that wrapper systems can not do.


If you have an existing code base or you want it to work outside of python and/or it is more than a couple of classes yes a code generator is a good choice. I think we need a little more information on what you are up to before we can really say run with product .


Thanks that helped a lot, but now i ran into another problem:
SWIG only creates functions and no modules/classes.
Which flags have to be set for swig to create modules?