I am using SWIG to generate the wrapper for python i.e. I am tring to correlate the c++ and python2.4. I am using the windowsXP platform with Visual Studio 2005 Editor and the Turbo c++ complier.
The problem is that after Generating the c++ file and the python file I am unable to compile the c++ file generated by SWIG.

Here is my sample c++ file :-


double My_var = 3.0;

int fact(int n)
    if(n<=1) return 1;
    else return n*fact(n-1);
int my_mod(int x,int y)
char *get_time()
    time_t ltime;
    return ctime(&ltime);

void  main()
    printf("\nFactorial of 5   = %d ",fact(5));
    printf("\nRemainder of 5/2 = %d",my_mod(5,2));
    printf("\nCurrent time     = %s",get_time());

And its related Interface file:-

/*    exx.i    */
%module exx
    /* Put header files here or function declarations like below    */
    extern double My_var;
    extern int fact(int n);
    extern int my_mod(int x,int y);
    extern char *get_time();    
%include exx.cpp

please help me.

Hi Everyone,
I have solved the problem myself.
I used the method given in the following link:-


In the phase setting up DLL,Instead off selecting a simple DLL I selected the Empty DLL.Simple DLL was given the following Error at the time of build:-

Performing Custom Build Step on .\example.i
example.cpp(6): Error: Syntax error in input(1).
Error executing c:\windows\system32\cmd.exe.

_example.dll - 1 error(s), 0 warning(s)

When I selected the empty DLL with the same method,It was running

I used MSVC 6.0 and python 2.4 on WindowsXP service pack 2 and SWIG-1.3.31 .

RSC, thanks for the reference. Working with SWIG can be interesting, but their seems to be lots of pitfalls to avoid!

This article has been dead for over six months. Start a new discussion instead.