Search code examples
pythonnumpycygwincython

Can't compile Cython code - unrecognized command line option '-mno-cygwin'


I am trying to compile some Python / Numpy code into Cython for speedup. I can compile just fine on my desktop - I copied my .pyx Cython file to my laptop to run it and after attempting to compile, I get the following error:

C:\Python27\MATH7450>python setup.py build_ext --inplace
running build_ext
cythoning heat.pyx to heat.c
building 'heat' extension
C:\strawberry\c\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python27\lib\site-pa
ckages\numpy\core\include -IC:\Python27\include -IC:\Python27\PC -c heat.c -o bu
ild\temp.win32-2.7\Release\heat.o
cc1.exe: error: unrecognized command line option '-mno-cygwin'
error: command 'gcc' failed with exit status 1

I'm running Windows 7 64 bit. I see it is using strawberry perl. I have the 32 bit version of strawberry perl installed. Again, it works just fine on my desktop, but getting this strange error when porting to laptop.


Solution

  • Per the Windows installation instructions of Cython, the recommended compiler is free Visual C++ 2008 Express, which can be installed from the offline installation Visual Studio 2008 Express iso.

    Alternatively Cython can use the MinGW and its gcc, although this is a reportedly more difficult route.

    From the output included in your question, Cython is trying to use the MinGW installation included with the Strawberry Perl distribution.

    My recommendation is to install Visual C++ 2008 Express, which from my experience works best for compiling Cython or other Python C extension modules.