473,812 Members | 2,907 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:examp le.c:(.text+0x5 5): undefined reference to `time'
example.o:examp le.c:(.text+0x6 0): 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 1627

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

Similar topics

1
4068
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 example. There is a little example in http://sebsauvage.net/python/mingw.html but it's not working for me. At more, I would like to used the dll versions of the glibc.
0
2096
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 attempting the example. Do I need some extra switches to get SWIG to create that function? Or is it something else? Here's my example build:
3
2823
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. Trying to build using mingw out of the cygwin environment but the final call to link the extension calls directly to 'cc' which I think should really be g++ at that point.
0
2408
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 simplified version of their example (just a void hello() {printf("Hello, world!\n");} and corresponding .i interface file, %module hello \ extern void hello();). I first do swig -perl5 hello.i which works fine.
0
1210
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 example.c example_wrap.c -I \ /usr/include/python2.4
3
3146
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... int doIt(char *a, MY_DIGIT **digit) { ... }
2
4459
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 */ #include <time.h>
0
1140
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 trying to point swig to my activepython installation. I'm doing this because my modules are all win32 installed, and not cygwin installed. Can anyone help me? I'm pointing to C:/python24/include and C:/python24/Libs.
0
1347
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 swig.org: http://www.swig.org/tutorial.html I have written example.c and example.i as described in the above tutorial. My first attempt at compiling the libraries was this:
0
10664
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10404
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10417
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10139
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9219
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5704
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4357
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3029
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.