SWIG and C++

Morfeas greek_bill at yahoo.com
Wed Sep 18 20:16:29 CEST 2002


I don't know if this is the right place to post this, but I couldn't find 
anywhere better.

I'm trying to use SWIG to interface C++ and python, but I'm getting an 
error. Here's what I have :

// Hello.h
class Hello
{
public:
        Hello(double aa, int bb);
        double GetA();
        double GetB();

private:
        double a;
        int b;
};


// Hello.i
%module Hello
%{
        #include "Hello.h"
%}

%include "Hello.h"


Then execute :
swig -proxy -c++ -python Hello.i
 g++ -c Hello_wrap.cxx -I/usr/include/python2.2/ 
 g++ --shared Hello_wrap.o Hello.o -o Hellomodule.so 
-I/usr/include/python2.2/

Python 2.2.1 (#1, Apr  9 2002, 13:10:27)
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-98)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Hello
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: dynamic module does not define init function (initHello)
>>>

Any clues? SWIG generates a Hello_wrap.cxx, which has a 
#define SWIG_init    init_Hello

is this related? Is there any way to fix this?

Thanks!
Morfeas

-- 
www.freecfm.com/m/morfeas



More information about the Python-list mailing list