<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1226" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi,</FONT></DIV>
<DIV><FONT face=Arial size=2> 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</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>python setup.py build -c mingw32</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Module:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>#include <Python.h></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>static PyObject *myfoo(PyObject *self, PyObject
*args, PyObject *keywords);</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>/* Module methods */</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>static PyMethodDef FooMethods[] = {<BR>
{"_myfoo", (PyCFunction) myfoo, METH_VARARGS|METH_KEYWORDS,
"FOO!"},<BR> {NULL, NULL, 0,
NULL} /* Sentinel
*/<BR>};</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>/* Initialize the module foo */</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>void initfoo(void)<BR>{<BR> PyObject
*module;<BR> module = Py_InitModule("foo", FooMethods);<BR>}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>static PyObject *myfoo(PyObject *self, PyObject
*args, PyObject *keywords)<BR>{<BR> int output_int;</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> char *keyword_list[] = {"output_int",
NULL};</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> if (! PyArg_ParseTupleAndKeywords(args,
keywords, "i", keyword_list, &output_int)) {<BR>
PyErr_SetObject(PyExc_TypeError, Py_BuildValue("OO", args, keywords));
<BR> return NULL;<BR> } </FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2> fprintf(stderr,"%d\n",
output_int);<BR> return(Py_None); <BR>}<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>Here is my setup.py file</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>from distutils.core import setup,
Extension<BR>import os</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial
size=2>libraries=[]<BR>library_dirs=[]<BR>include_dirs=[]</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>mincutils_mod =
[]<BR>mincutils_mod.append(Extension('foo', sources =
['foo.c'],<BR>
include_dirs=include_dirs,<BR>
library_dirs=library_dirs,<BR>
libraries=libraries))<BR>
<BR>setup (name = 'foo',<BR> version =
'0.4',<BR> description = 'This is a package
to foo.',<BR> author = 'Jonathan E.
Taylor',<BR> author_email = <A
href="mailto:'jonathan.taylor@stanford.edu'">'jonathan.taylor@stanford.edu'</A>,<BR>
url = '',<BR> long_description =
'''<BR>''',<BR> ext_modules =
mincutils_mod)</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>and the error messages:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>F:\Python Example>python setup.py build -c
mingw32<BR>running build<BR>running build_ext<BR>building 'foo'
extension<BR>writing
build\temp.win32-2.3\Release\foo.def<BR>F:\MinGW\bin\gcc.exe -mno-cygwin -shared
-s build\temp.win32-2.3\Release\foo.o b<BR>uild\temp.win32-2.3\Release\foo.def
-LF:\Python23\libs -LF:\Python23\PCBuild -lp<BR>ython23 -o
build\lib.win32-2.3\foo.pyd<BR>build\temp.win32-2.3\Release\foo.o(.text+0x94):foo.c:
undefined reference to
`_i<BR>mp__PyExc_TypeError'<BR>build\temp.win32-2.3\Release\foo.o(.text+0xc1):foo.c:
undefined reference to `_i<BR>mp___Py_NoneStruct'<BR>error: command 'gcc' failed
with exit status 1<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>Any help would be greatly appreciated.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thanks,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Jonathan Taylor</DIV>
<DIV><BR></DIV></FONT></BODY></HTML>