Cython error: C:\Python27\libs/libpython27.a: error adding symbols
<p>I'm doing my first test with Cython. Basically the <code>hello.pyx</code> example from <a href="http://docs.cython.org/src/quickstart/build.html" rel="nofollow noreferrer">http://docs.cython.org/src/quickstart/build.html</a></p>

<p>When I want to compile I get the following error:</p>

<pre><code>C:[...]&gt;python setup.py build_ext --inplace
Compiling hello.pyx because it changed.
[1/1] Cythonizing hello.pyx
running build_ext
building 'hello' extension
C:\MinGW\bin\gcc.exe -mdll -O -Wall -IC:\Python27\include -IC:\Python27\PC -c he
llo.c -o build\temp.win32-2.7\Release\hello.o
writing build\temp.win32-2.7\Release\hello.def
C:\MinGW\bin\gcc.exe -shared -s build\temp.win32-2.7\Release\hello.o build\temp.
win32-2.7\Release\hello.def -LC:\Python27\libs -LC:\Python27\PCbuild -lpython27
-lmsvcr90 -o C:\Users\Bernd\Documents\99_Projekte\ONGOING\201412_Laufauswertung\
Repro\Tests\hello.pyd
C:\Python27\libs/libpython27.a: error adding symbols: File format not recognized

collect2.exe: error: ld returned 1 exit status
error: command 'C:\\MinGW\\bin\\gcc.exe' failed with exit status 1
</code></pre>

<p>The file <code>hello.c</code> is generated. </p>

<p>Any idea?</p>

<p><strong>Edit 1:</strong></p>

<p>Following the hint from J.J. Hakala, i did the following: move <code>libpython27.a</code> away from <code>C:\Python27\libs</code> (for example bak subdirectory), and copy <code>python27.dll</code> from <code>c:\windows\system32 to c:\python27\libs</code>  </p>

<p>Now the result is: </p>

<pre><code>C:[...]&gt;python setup.py build_ext --inplace
running build_ext
building 'hello' extension
C:\MinGW\bin\gcc.exe -mdll -O -Wall -IC:\Python27\include -IC:\Python27\PC -c he
llo.c -o build\temp.win32-2.7\Release\hello.o
writing build\temp.win32-2.7\Release\hello.def
C:\MinGW\bin\gcc.exe -shared -s build\temp.win32-2.7\Release\hello.o build\temp.
win32-2.7\Release\hello.def -LC:\Python27\libs -LC:\Python27\PCbuild -lpython27
-lmsvcr90 -o C:\Users\Bernd\Documents\99_Projekte\ONGOING\201412_Laufauswertung\
Repro\Tests\hello.pyd
build\temp.win32-2.7\Release\hello.o:hello.c:(.text+0x2d9): undefined reference
to `_imp___PyThreadState_Current'
build\temp.win32-2.7\Release\hello.o:hello.c:(.text+0x3b3): undefined reference
to `_imp__PyExc_RuntimeError'
build\temp.win32-2.7\Release\hello.o:hello.c:(.text+0x444): undefined reference
to `_imp___Py_NoneStruct'
build\temp.win32-2.7\Release\hello.o:hello.c:(.text+0x8e1): undefined reference
to `_imp__PyExc_ImportError'
collect2.exe: error: ld returned 1 exit status
error: command 'C:\\MinGW\\bin\\gcc.exe' failed with exit status 1
</code></pre>

<p>A folder <code>build\temp.win32-2.7\Release</code> with the files <code>hello.def</code> and <code>hello.o</code> is generated. </p>

<p><strong>Edit 2:</strong>
Maybe the solution is here: <a href="https://stackoverflow.com/questions/32440789/compiling-cython-with-mingw-undefined-reference-pyexc">compiling Cython with MinGW - undefined reference PyExc</a></p>

<p>I'll try to install Visual Studio and then try again. Recommendation on how to make it run on MinGW are still wellcome.</p>