Hi,
I have a possibly stupid question -- my apologies. I am trying to build some modules written on a Linux platform in Windows (Windows 2000) using mingw32. I have tried building the following REALLY basic module and am getting some strange errors (it works fine with VC++ 6.0). My command line is
python setup.py build -c mingw32
Module:
#include
static PyObject *myfoo(PyObject *self, PyObject *args, PyObject *keywords);
/* Module methods */
static PyMethodDef FooMethods[] = {
{"_myfoo", (PyCFunction) myfoo, METH_VARARGS|METH_KEYWORDS, "FOO!"},
{NULL, NULL, 0, NULL} /* Sentinel */
};
/* Initialize the module foo */
void initfoo(void)
{
PyObject *module;
module = Py_InitModule("foo", FooMethods);
}
static PyObject *myfoo(PyObject *self, PyObject *args, PyObject *keywords)
{
int output_int;
char *keyword_list[] = {"output_int", NULL};
if (! PyArg_ParseTupleAndKeywords(args, keywords, "i", keyword_list, &output_int)) {
PyErr_SetObject(PyExc_TypeError, Py_BuildValue("OO", args, keywords));
return NULL;
}
fprintf(stderr,"%d\n", output_int);
return(Py_None);
}
Here is my setup.py file
from distutils.core import setup, Extension
import os
libraries=[]
library_dirs=[]
include_dirs=[]
mincutils_mod = []
mincutils_mod.append(Extension('foo', sources = ['foo.c'],
include_dirs=include_dirs,
library_dirs=library_dirs,
libraries=libraries))
setup (name = 'foo',
version = '0.4',
description = 'This is a package to foo.',
author = 'Jonathan E. Taylor',
author_email = 'jonathan.taylor@stanford.edu',
url = '',
long_description = '''
''',
ext_modules = mincutils_mod)
and the error messages:
F:\Python Example>python setup.py build -c mingw32
running build
running build_ext
building 'foo' extension
writing build\temp.win32-2.3\Release\foo.def
F:\MinGW\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.3\Release\foo.o b
uild\temp.win32-2.3\Release\foo.def -LF:\Python23\libs -LF:\Python23\PCBuild -lp
ython23 -o build\lib.win32-2.3\foo.pyd
build\temp.win32-2.3\Release\foo.o(.text+0x94):foo.c: undefined reference to `_i
mp__PyExc_TypeError'
build\temp.win32-2.3\Release\foo.o(.text+0xc1):foo.c: undefined reference to `_i
mp___Py_NoneStruct'
error: command 'gcc' failed with exit status 1
Any help would be greatly appreciated.
Thanks,
Jonathan Taylor