473,406 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 <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;
time(&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
_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 "<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 1610

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: orion30 | last post by:
I would like to know if somebody has successfully uses SWIF using MSYS / MINGW32 / PYTHON. I tried to do it but apparently, I failed. Is there somebody who can help me and give a little...
0
by: Phil Schmidt | last post by:
I'm attempting to follow the instructions at http://sebsauvage.net/python/mingw.html, without luck. I have Python 2.3, MinGW 3.2.3, ans SWIG 1.3.19. I get an export error on "initexample" when...
3
by: Kevin Dahlhausen | last post by:
Could anyone post a simple setup.py script that uses a SWIG interface to C++ code and the mingw compiler? I followed some online samples, and am using the setup.cfg file to specify swig-c++=1....
0
by: ReaprZero | last post by:
Hi, I'm using Cygwin and ActiveState perl to try to compile a sample application using SWIG. I'm using the short tutorial from http://www.swig.org/tutorial.html (the perl part of it), but with a...
0
by: Jerry He | last post by:
Hi, I just installed SWIG on Windows(Cygwin) and tried to use it to compile some of the example python programs. For the first two commands it produced no error swig -python example.i gcc -c...
3
by: Java and Swing | last post by:
I've tried sending a email to the swig mailing list 3 times...but it never seems to get it...not sure what is going on, still looking into it. Until then... I now have a C function such as... ...
2
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
0
by: stumblecrab | last post by:
Hello, I've looked at the swig example in the back of "programming python" (Lutz). Using gcc to compile a swig wrapper I'm getting lots of errors. Instead of using the cygwin python, I'm...
0
by: Basha J P M | last post by:
I am beginner in python. I am working through the tutorial examples from http://www.swig.org/ and have run into some problems. I took the following command instructions from the tutorial on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.