RE: SWIG problems with gcc and Cygwin?

2006-06-27 Thread Michael Yanowitz
Thanks.
   It now works for me in Cygwin.
I would never have guessed to write it as a dll.

Michael Yanowitz

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of Norman Vine
Sent: Tuesday, June 27, 2006 4:21 PM
To: python-list@python.org
Subject: Re: SWIG problems with gcc and Cygwin?



"Michael Yanowitz"wrote
> >
>I am just trying out SWIG, but quickly ran into problems.
> Using Cygwin gcc, I tried the following:
>
> 3)ran in cygwin:  swig -i python example.i

try
'swig -python example.i'

> 4)Attempted to run on cygwin:  ld -shared example.o example_wrap.o -o
> _example.so


try
$ gcc -I/usr/include/python2.4 -L/lib/python2.4/config --shared example.c
example_wrap.c -lpython2.4 -o _example.dll

$ python
Python 2.4.1 (#1, May 27 2005, 18:02:40)
[GCC 3.3.3 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from example import *
>>> get_time()
'Tue Jun 27 16:17:41 2006\n'

HTH

Norman

--
http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SWIG problems with gcc and Cygwin?

2006-06-27 Thread Norman Vine

"Michael Yanowitz"wrote 
> > 
>I am just trying out SWIG, but quickly ran into problems.
> Using Cygwin gcc, I tried the following:
> 
> 3)ran in cygwin:  swig -i python example.i

try  
'swig -python example.i'

> 4)Attempted to run on cygwin:  ld -shared example.o example_wrap.o -o
> _example.so


try
$ gcc -I/usr/include/python2.4 -L/lib/python2.4/config --shared example.c 
example_wrap.c -lpython2.4 -o _example.dll

$ python
Python 2.4.1 (#1, May 27 2005, 18:02:40)
[GCC 3.3.3 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from example import *
>>> get_time()
'Tue Jun 27 16:17:41 2006\n'

HTH

Norman

-- 
http://mail.python.org/mailman/listinfo/python-list


RE: SWIG problems with gcc and Cygwin?

2006-06-27 Thread Michael Yanowitz
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of Steve Holden
Sent: Tuesday, June 27, 2006 2:55 AM
To: python-list@python.org
Subject: Re: SWIG problems with gcc and Cygwin?


Michael Yanowitz wrote:
>   No response yet. The SWIG test works fine in Linux no problems.
> However, I still have the problem in Cygwin.
>   Also, not sure if related but I do have a win32 Python 2.4.3 and
> Cygwin Python 2.4.1. Not sure if there are any conflicts. Any advice
> in making these two co-exist?
>   The only C/C++ compiler I have presently is Cygwin gcc.
>
I wouldn't claim to be an expert but it looks like you are missing
libraries. Shouldn't you at least be loading -l c to get functions
defined in libc?

regards
  Steve
--
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Love me, love my blog  http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden


   Possibly. I thought of that, but Linux doesn't require that I link in
the C Library. Maybe Cygwin does or maybe a parameter is needed in gcc
to do that automatically. The sample program (in
http://www.swig.org/tutorial.html )
does not mention this.

Thanks:
Michael Yanowitz

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SWIG problems with gcc and Cygwin?

2006-06-26 Thread Steve Holden
Michael Yanowitz wrote:
>   No response yet. The SWIG test works fine in Linux no problems.
> However, I still have the problem in Cygwin.
>   Also, not sure if related but I do have a win32 Python 2.4.3 and
> Cygwin Python 2.4.1. Not sure if there are any conflicts. Any advice
> in making these two co-exist?
>   The only C/C++ compiler I have presently is Cygwin gcc.
> 
I wouldn't claim to be an expert but it looks like you are missing 
libraries. Shouldn't you at least be loading -l c to get functions 
defined in libc?

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Love me, love my blog  http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SWIG problems with gcc and Cygwin?

2006-06-26 Thread Istvan Albert
Michael Yanowitz wrote:

>   Also, not sure if related but I do have a win32 Python 2.4.3 and
> Cygwin Python 2.4.1. Not sure if there are any conflicts. Any advice
> in making these two co-exist?

SWIG will work with the windows and cygwin python, just make sure you
don't mix the various platforms.

- Install two separate versions of swig one for windows (binary) and
compile one in cygwin,
- Pay attention to the path and make sure that you invoke the correct
swig and python 

Istvan.

-- 
http://mail.python.org/mailman/listinfo/python-list


RE: SWIG problems with gcc and Cygwin?

2006-06-26 Thread Michael Yanowitz
  No response yet. The SWIG test works fine in Linux no problems.
However, I still have the problem in Cygwin.
  Also, not sure if related but I do have a win32 Python 2.4.3 and
Cygwin Python 2.4.1. Not sure if there are any conflicts. Any advice
in making these two co-exist?
  The only C/C++ compiler I have presently is Cygwin gcc.

Thanks in advance:
Michael Yanowitz

-Original Message-

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf
Of Michael Yanowitz
Sent: Tuesday, June 20, 2006 3:39 PM
To: python-list@python.org
Subject: SWIG problems with gcc and Cygwin?


Hello:

   I am just trying out SWIG, but quickly ran into problems.
Using Cygwin gcc, I tried the following:

1) Created example.c (as given on http://www.swig.org/tutorial.html )
/* File : example.c */

 #include 
 double My_variable = 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(<ime);
 return ctime(<ime);
 }

2) Create interface file, example.i

/* example.i */
 %module example
 %{
 /* Put header files here or function declarations like below */
 extern double My_variable;
 extern int fact(int n);
 extern int my_mod(int x, int y);
 extern char *get_time();
 %}

 extern double My_variable;
 extern int fact(int n);
 extern int my_mod(int x, int y);
 extern char *get_time();

3)ran in cygwin:  swig -i python example.i

4)Attempted to run on cygwin:  ld -shared example.o example_wrap.o -o
_example.so
But got back many errors:
example.o:example.c:(.text+0x55): undefined reference to `time'
example.o:example.c:(.text+0x60): undefined reference to `ctime'
example_wrap.o:example_wrap.c:(.text+0x9c): undefined reference to `strlen'
example_wrap.o:example_wrap.c:(.text+0x12c): undefined reference to `strlen'
example_wrap.o:example_wrap.c:(.text+0x1dd): undefined reference to `strcmp'
example_wrap.o:example_wrap.c:(.text+0x494): undefined reference to `strcmp'
example_wrap.o:example_wrap.c:(.text+0x748): undefined reference to `strlen'
example_wrap.o:example_wrap.c:(.text+0x779): undefined reference to `strcpy'
example_wrap.o:example_wrap.c:(.text+0x7a5): undefined reference to `strcmp'
example_wrap.o:example_wrap.c:(.text+0x805): undefined reference to `strlen'
example_wrap.o:example_wrap.c:(.text+0x877): undefined reference to
`strncpy'
example_wrap.o:example_wrap.c:(.text+0x8ab): undefined reference to `strcmp'
example_wrap.o:example_wrap.c:(.text+0x8c9): undefined reference to `memset'
example_wrap.o:example_wrap.c:(.text+0x948): undefined reference to `fputs'
example_wrap.o:example_wrap.c:(.text+0x95d): undefined reference to `fputs'
example_wrap.o:example_wrap.c:(.text+0x970): undefined reference to `fputs'
example_wrap.o:example_wrap.c:(.text+0x9db): undefined reference to
`PyString_Fr
omFormat'
example_wrap.o:example_wrap.c:(.text+0xa3a): undefined reference to
`PyString_Fr
omString'
example_wrap.o:example_wrap.c:(.text+0xa68): undefined reference to
`PyLong_From
VoidPtr'
example_wrap.o:example_wrap.c:(.text+0xa83): undefined reference to
`PyTuple_New
  etc...

  Any idea what I am doing wrong or omitted?

Of course when I then try to go into python and
import example, I get:

>>> import example
Traceback (most recent call last):
  File "", line 1, in ?
  File "example.py", line 5, in ?
import _example
ImportError: No module named _example

Thanks in advance:
Michael Yanowitz

--
http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


SWIG problems with gcc and Cygwin?

2006-06-20 Thread Michael Yanowitz
Hello:

   I am just trying out SWIG, but quickly ran into problems.
Using Cygwin gcc, I tried the following:

1) Created example.c (as given on http://www.swig.org/tutorial.html )
/* File : example.c */

 #include 
 double My_variable = 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(>> import example
Traceback (most recent call last):
  File "", line 1, in ?
  File "example.py", line 5, in ?
import _example
ImportError: No module named _example

Thanks in advance:
Michael Yanowitz

-- 
http://mail.python.org/mailman/listinfo/python-list