building modules with swig- mingGW compiler
Craig Howard
craighoward at bellsouth.net
Sun Jan 5 15:27:21 EST 2003
Hi:
I'm using python 2.2.2, swig 1.3.17, and minGW in order to build a simple
python module, and am running into an error.
I've created the libpython22.a, and added the following changes to
build_ext.py:
#new_sources.append(base + target_ext) # old
new_sources.append(base + '_wrap' + target_ext) # new
#swig_cmd = [swig, "-python", "-dnone", "-ISWIG"] # old
swig_cmd = [swig, "-python"] # new
I've created a file example.c:
/* 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(<ime);
return ctime(<ime);
}
I've created a file example.i
/* example.i */
%module example
%{
/* Put header files here (optional) */
%}
extern double My_variable;
extern int fact(int n);
extern int my_mod(int x, int y);
extern char *get_time();
I've created a file setup.py:
# setup.py
import distutils
from distutils.core import setup, Extension
setup(name = "Simple example from the SWIG website",
version = "2.2",
ext_modules = [Extension("example", ["example.i","example.c"])])
Then I run the command: python setup.py build -cmingw32
and I get an error:
example.exp(.edata+0x34):fake: undefined reference to 'initexample'
dllwrap: gcc exited with status 1
error: command 'dllwrap' failed with exit status 1
More information about the Python-list
mailing list