Issue 762614: problem building c extension with minGW on Windows (original) (raw)

I am having problems building C extension on Python 2.3b1 on Windows 2000 with latest minGW. The culprit seems to be calling of Py_None. Here is a test module, which builds happily on python 2.2.3.

Here is build options: gcc -mno-cygwin -mdll -O -Wall -Id:\fuming\lib\python\include -c spam.c -o spam.o

dllwrap -mno-cygwin -mdll -static --dllname spam.pyd --driver-name gcc --def spam.def -o spam.pyd s pam.o -s --entry _DllMain@12 --target=i386-mingw32 -Ld:\fuming\lib\python\libs -lpython23

Here is the error message I get on Python 2.3b1: spam.o(.text+0x60):spam.c: undefined reference to _imp___Py_NoneStruct' spam.o(.text+0x68):spam.c: undefined reference to _imp___Py_NoneStruct' dllwrap: gcc exited with status 1

Here is the source code:

/* c function */ static PyObject * spam_system(PyObject *self, PyObject *input_str) { char *local_string; int length;

if (!PyArg_ParseTuple(input_str, "s#",

&local_string, &length)) { return NULL; }

printf("%s\n", local_string);        
printf("number of letters = %d\n", length);


Py_INCREF(Py_None);
return Py_None;


/*
return Py_BuildValue("i", length);
*/

};