SWIG and Python

View: New views
3 Messages — Rating Filter:   Alert me  

SWIG and Python

by JBudOnw :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hey guys, this is probably going to be the most basic question you'll see on here, but I have looked everywhere (including this forum board/mailing list) to figure it out, and I still can't find it. I'm using SWIG with Python (as this says), and I've been trying it out with Python 2.4 (since I read up that later versions of Python won't work). I've downloaded and installed Cygwin and devel inside of it. I've also installed PRC tools (which includes gcc in it). I've made my environment variables, the paths link to swig and gcc. I'll make my .c file, I've tried a lot of things but the example I'll show you was:

 /* File: example.c */
 
 int funct() {
   return 0;
 }

and I've made a .i file:

%module example

%{
%}

extern int funct();


which is named example.i   Next I wrap my c code within cygwin:

$ swig -python example.i


and I've received my example_wrap.c and example.py. Next I follow instructions (no idea what this next line does) and do this:

$ gcc -c example.c

and that works out fine, I get my example.o file. Finally I try out the next line I'm required to use:

gcc -I/usr/include/python2.4 -c example_wrap.c
(it didn't work, but I thought it looked a little funny so I changed it around to..)
gcc C:/Python24/include -c example_wrap.c

I tried that other line since that's where my pyconfig.h and Python.h file are both located. When I do this I get a huge number of errors all flooded out at me, all of them complaining about example_wrap.c. I could copy some of the errors out if you guys want, but it has numerous complaints for just about every line (up to line 3212) within example_wrap.c.  I'm sure it's something really obvious and simple, but I've tried numerous tutorials and methods and changing around environment variables and code and everything, I think it's time to ask for help. Any ideas? Thanks so much for any help, it's really appreciated.






-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

Re: SWIG and Python

by Christopher Barker :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Lourve Struck wrote:
> I've been trying it out with
> Python 2.4 (since I read up that later versions of Python won't work).

Won't work for what? 2.5 has been out and stable a long time now.

> $ gcc -c example.c

You really want to build with distutils:

http://www.swig.org/Doc1.3/Python.html#Python_nn6

We really need to rename those docs something other that "Development
Docs" the other ones are very, very old, at least with respect to
building extensions with Python.

-Chris


--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker@...

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

Re: SWIG and Python

by Christopher Barker :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Christopher Barker wrote:
> We really need to rename those docs something other that "Development
> Docs" the other ones are very, very old, at least with respect to
> building extensions with Python.

And update the "Building a Python Module" section here:

http://www.swig.org/Doc1.3/Introduction.html#Introduction_nn8


-Chris


--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker@...

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user
LightInTheBox - Buy quality products at wholesale price