7

I'm struggling with installing Cython on Windows 7 x64. I downloaded and installed the automated MinGW installer. The created a distutils.cfg to the distutils folder with the following content:

[build]
compiler = mingw32

After adding C:\MinGW\bin to the environment variables, I called easy_install Cython but I get the following errors. Raping the internet did really not give me helpful resulsts as all this compiling stuff (or should I say sh*t ?) is so new to me.

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

Any ideas whats wrong ? Thanks !

UPDATE: I used dlltools to create libpython27.a and then again tried to build Cython and it just worked fine ! But now, calling cython.exe delivers this error:

ImportError: DLL load failed, %1 is not a valid Win32-executable.

I assume this is because I use Pythonx64 but the MinGW32 compiler ? So, how can i compile it for x64 ?

agf
  • 171,228
  • 44
  • 289
  • 238
Niklas R
  • 16,299
  • 28
  • 108
  • 203
  • @lance What did you change ? // ah the title. – Niklas R Aug 08 '11 at 12:34
  • 1
    The title. You can see a summary of revision edits by clicking on the "X mins ago" text which appears directly after the word "edited " above my avatar above. – lance Aug 08 '11 at 12:35
  • 1
    Can I recommend just using x86 python? Tons of packages are much harder to install/find/compile for x64 and every benchmark I've seen has x64 python trailing performance. Someone explained some of the design issues with x64 python and from then on I decided that it was not ready for primetime. – marr75 Aug 08 '11 at 13:46
  • Thanks, I finally changed to x86 Python and that did work ! :) – Niklas R Aug 08 '11 at 14:58

1 Answers1

11

There are pre-compiled Cython packages on this site. I'd suggest you to switch to x86 Python, you gain no real advantage by using the x64 version. If you want to stick with x64, you can't use MingW and you have to use MS SDK C++ compiler (more on this).

Do not use MinGW-w64. As you will notice, the MinGW import library for Python (e.g. libpython27.a) is omitted from the AMD64 version of Python. This is deliberate. Do not try to make one using dlltool. [...] There have also been issues with the mingw runtime conflicting with the MSVC runtime; this can happen from places you don't expect, such as inside runtime libraries for g++ or gfortran.

leoluk
  • 12,561
  • 6
  • 44
  • 51