471,337 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

SWIG & C Extensions, win32 & MinGW: undefined reference


Going through the tutorial on http://swig.org, I created the example files
(pasted below). After generating the _wrap file, I tried compiling (using
mingw32) and received a lot of undefined reference compiler errors:

...\build\temp.win32-2.5\Release\example_wrap.o:example_wrap.c:(.text+0 x670f):
undefined reference to `_imp__PyExc_MemoryError'

there are many other similar errors all prefaced with _imp__Py, so I am
assuming there is a linker error with the python libraries. I have adjusted
my PATH variable to include all the python directories (libs/dlls), so I am
unclear what else I can try. Any suggestions?
FILES FROM TUTORIAL:
//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);
}
//************************************************** *************

//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();
//************************************************** *************

//setup.py
from distutils.core import setup, Extension

setup(name='example',
version = '1.0',
ext_modules=[
Extension('example', ['example.c', 'example.i'])
])

//************************************************** *************
--
View this message in context: http://www.nabble.com/SWIG---C-Exten...p14373972.html
Sent from the Python - python-list mailing list archive at Nabble.com.

Dec 17 '07 #1
0 1394

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Phil Schmidt | last post: by
reply views Thread by A. B., Khalid | last post: by
3 posts views Thread by Kevin Dahlhausen | last post: by
reply views Thread by Jerry He | last post: by
1 post views Thread by superprad | last post: by
reply views Thread by Michael Yanowitz | last post: by
2 posts views Thread by eliben | last post: by
reply views Thread by rosydwin | last post: by

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.