SWIG & C Extensions, win32 & MinGW: undefined reference


N

newbie73

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+0x670f):
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'])
])

//***************************************************************
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top