469,934 Members | 1,509 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,934 developers. It's quick & easy.

SWIG problems with gcc and Cygwin?


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 <time.h>
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;
return ctime(&ltime);

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
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
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
example_wrap.o:example_wrap.c:(.text+0xa3a): undefined reference to
example_wrap.o:example_wrap.c:(.text+0xa68): undefined reference to
example_wrap.o:example_wrap.c:(.text+0xa83): undefined reference to

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 "<stdin>", line 1, in ?
File "example.py", line 5, in ?
import _example
ImportError: No module named _example

Thanks in advance:
Michael Yanowitz

Jun 20 '06 #1
0 1491

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by orion30 | last post: by
reply views Thread by Phil Schmidt | last post: by
3 posts views Thread by Kevin Dahlhausen | last post: by
reply views Thread by ReaprZero | last post: by
reply views Thread by Jerry He | last post: by
3 posts views Thread by Java and Swing | last post: by
2 posts views Thread by ajikoe | last post: by
reply views Thread by stumblecrab | last post: by
reply views Thread by Basha J P M | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.