在Windows 10中,我安装了Python 2.7和Cython 0.28。我安装了MinGW并将其添加到path
。
我尝试从Cython's tutorial编译python代码。
当我在包含python setup.py build_ext --inplace
和helloworld.pyx
文件的目录中使用setup.py
时,我收到以下错误:
running build_ext
building 'helloworld' extension
C:\MinGW\bin\gcc.exe -mdll -O -Wall -IC:\Python27\include -IC:\Python27\PC -c helloworld.c -o build\temp.win-amd64-2.7\Release\helloworld.o
writing build\temp.win-amd64-2.7\Release\helloworld.def
C:\MinGW\bin\gcc.exe -shared -s build\temp.win-amd64-2.7\Release\helloworld.o build\temp.win-amd64-2.7\Release\helloworld.def -LC:\Python27\libs -LC:\Python27\PCbuild\amd64 -LC:\Python27\PC\VS9.0\amd64 -lpython27 -lmsvcr90 -o C:\Users\MyPC\helloworld.pyd
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x93): undefined reference to `_imp__PyOS_snprintf'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x9b): undefined reference to `_imp__Py_GetVersion'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x107): undefined reference to `_imp__PyOS_snprintf'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x120): undefined reference to `_imp__PyErr_WarnEx'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x160): undefined reference to `_imp__PyString_FromStringAndSize'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x166): undefined reference to `_imp__PyString_InternFromString'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x186): undefined reference to `_imp__PyUnicodeUCS2_DecodeUTF8'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x1af): undefined reference to `_imp__PyObject_Hash'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x21e): undefined reference to `_imp__PyFile_SoftSpace'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x233): undefined reference to `_imp__PyFile_WriteString'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x250): undefined reference to `_imp__PyFile_WriteObject'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x265): undefined reference to `_imp__PyFile_WriteString'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x296): undefined reference to `_imp__PySys_GetObject'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x2ad): undefined reference to `_imp__PyExc_RuntimeError'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x2b8): undefined reference to `_imp__PyErr_SetString'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x2fd): undefined reference to `_imp___PyThreadState_Current'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x36f): undefined reference to `_imp__PyFrame_New'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x389): undefined reference to `_imp__PyTraceBack_Here'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x3ef): undefined reference to `_imp___PyObject_GetDictPtr'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x40c): undefined reference to `_imp__PyDict_GetItem'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x41f): undefined reference to `_imp__PyObject_Not'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x4be): undefined reference to `_imp__PyObject_Not'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x4c4): undefined reference to `_imp___Py_ZeroStruct'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x4ce): undefined reference to `_imp___Py_TrueStruct'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x50f): undefined reference to `_imp__PyObject_GetAttr'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x519): undefined reference to `_imp__PyErr_Clear'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x51e): undefined reference to `_imp___Py_ZeroStruct'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x539): undefined reference to `_imp__PyObject_SetAttr'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x589): undefined reference to `_imp__PyString_FromString'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x5c0): undefined reference to `_imp__PyString_FromFormat'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x62c): undefined reference to `_imp__PyCode_New'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x709): undefined reference to `_imp__PyString_FromString'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x746): undefined reference to `_imp__PyMem_Malloc'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x7e0): undefined reference to `_imp__PyMem_Realloc'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x870): undefined reference to `_imp__PyTuple_New'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x88e): undefined reference to `_imp__PyString_FromStringAndSize'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x8ac): undefined reference to `_imp__PyUnicodeUCS2_FromStringAndSize'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x8dd): undefined reference to `_imp__Py_InitModule4'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x8f5): undefined reference to `_imp__PyModule_GetDict'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x90a): undefined reference to `_imp__PyImport_AddModule'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x949): undefined reference to `_imp__PyObject_SetAttrString'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x9cd): undefined reference to `_imp__PyDict_New'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0x9f2): undefined reference to `_imp__PyDict_SetItem'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0xa87): undefined reference to `_imp__PyErr_Occurred'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0xa90): undefined reference to `_imp__PyExc_ImportError'
build\temp.win-amd64-2.7\Release\helloworld.o:helloworld.c:(.text+0xaa3): undefined reference to `_imp__PyErr_SetString'
collect2.exe: error: ld returned 1 exit status
error: command 'C:\\MinGW\\bin\\gcc.exe' failed with exit status 1
这些错误的原因是什么?