Cython在Windows 7 x64无法编译

7
我正在尝试在Windows 7 x64上安装Cython。 我已经下载并安装了“自动化MinGW安装程序”。然后,在distutils文件夹中创建了一个distutils.cfg文件,并添加了以下内容:
[build]
compiler = mingw32

在将C:\MinGW\bin添加到环境变量后,我调用easy_install Cython但是出现以下错误。搜寻互联网并没有给我提供有用的结果,因为这个编译的东西对我来说还很陌生(或者我应该说很烂)。
c:\users\niklas\appdata\local\temp\easy_install-dgjjub\cython-0.15\cython\plex\scanners.o:Scanners.c:(.text+0x5d59): undefined reference to `_imp__PyObject_GetAttr'
c:\users\niklas\appdata\local\temp\easy_install-dgjjub\cython-0.15\cython\plex\scanners.o:Scanners.c:(.text+0x5dc5): undefined reference to `_imp__PyObject_GetAttr'
c:\users\niklas\appdata\local\temp\easy_install-dgjjub\cython-0.15\cython\plex\scanners.o:Scanners.c:(.text+0x5e31): undefined reference to `_imp__PyObject_GetAttr'
c:\users\niklas\appdata\local\temp\easy_install-dgjjub\cython-0.15\cython\plex\scanners.o:Scanners.c:(.text+0x5ebc): undefined reference to `_imp__PyObject_Call'
c:\users\niklas\appdata\local\temp\easy_install-dgjjub\cython-0.15\cython\plex\scanners.o:Scanners.c:(.text+0x5f08): undefined reference to `_imp__PyDict_New'
c:\users\niklas\appdata\local\temp\easy_install-dgjjub\cython-0.15\cython\plex\scanners.o:Scanners.c:(.text+0x5f49): undefined reference to `_imp__PyObject_SetAttr'
c:\users\niklas\appdata\local\temp\easy_install-dgjjub\cython-0.15\cython\plex\scanners.o:Scanners.c:(.text+0x5ffe): undefined reference to `_imp__PyErr_Occurred'
c:\users\niklas\appdata\local\temp\easy_install-dgjjub\cython-0.15\cython\plex\scanners.o:Scanners.c:(.text+0x6013): undefined reference to `_imp__PyExc_ImportError'
c:\users\niklas\appdata\local\temp\easy_install-dgjjub\cython-0.15\cython\plex\scanners.o:Scanners.c:(.text+0x601e): undefined reference to `_imp__PyErr_SetString'
c:\users\niklas\appdata\local\temp\easy_install-dgjjub\cython-0.15\cython\plex\scanners.o:Scanners.c:(.text+0x602d): undefined reference to `_imp__PyInt_FromLong'
collect2: ld returned 1 exit status
dllwrap: gcc exited with status 1
error: Setup script exited with error: command 'dllwrap' failed with exit status 1

任何想法出了什么问题吗?谢谢!
更新:我使用dlltools创建了libpython27.a,然后再次尝试构建Cython,它正常工作了!但是现在,调用cython.exe会产生这个错误:
ImportError: DLL load failed, %1 is not a valid Win32-executable.

我猜这是因为我使用的是Pythonx64,但MinGW32编译器不支持。那么,我该如何为x64编译它?

@lance 你改了什么?//啊,标题。 - Niklas R
1
您可以通过单击我的头像上方“编辑”一词之后直接出现的“X分钟前”文本,查看修订编辑的摘要。 - lance
1
我可以推荐只使用x86 Python吗?许多软件包在x64上安装/查找/编译要困难得多,而且我看到的所有基准测试都表明x64 Python性能不如x86。有人解释了一些x64 Python的设计问题,从那时起,我就决定它还没有准备好用于生产环境。 - marr75
谢谢,我最终改用x86 Python,确实可以工作! :) - Niklas R
1个回答

11

这个网站上有预编译的Cython软件包。我建议你切换到x86 Python,因为使用x64版本没有实际优势。如果想继续使用x64,则不能使用MingW,必须使用MS SDK C ++编译器(更多信息)。

不要使用MinGW-w64。如您所见,Python的AMD64版本中省略了MinGW导入库文件(例如libpython27.a)。这是故意的。不要尝试使用dlltool创建它。[...] Mingw运行时库也会与MSVC运行时库发生冲突;这可能会发生在您意想不到的地方,例如g++或gfortran的运行时库中。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接