Hi,
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 :-

#include<stdio.h>
#include<time.h>

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)
{
    return(x%y);
}
char *get_time()
{
    time_t ltime;
    time(&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:-

http://www.geocities.com/foetsch/python/extending_python.htm#dll

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

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.