Useful libraries/frameworks

Compiling cython code with mingw-w64 compiler (Windows)

64bit environment

-DMS_WIN64 is needed when compiling. Otherwise important variable type declarations are wrong during the compilation and even if the compilation was successful, the result would be unusable.

undefined reference to _imp___PyThreadState_Current when linking

Although gcc seems to parse the contents of a lib file, for example C:\Python34\python34.lib, there may be linking errors. These can be solved by creating libpython34.dll.a with gendef, for example in 64bit msys shell

gendef c:/Windows/System32/python34.dll
dlltool -U -d python34.def -l libpython34.dll.a
cp libpython34.dll.a c:/Python34/libs

gcc will now use this file in preference.

undefined reference to 'WinMain@16'

This may happen when trying to link code produced by cython --embed to an executable. In a C-file produced by cython there will be definition for main

#if PY_MAJOR_VERSION < 3
int main(int argc, char** argv) {
#elif defined(WIN32) || defined(MS_WINDOWS)
int wmain(int argc, wchar_t **argv) {

In case of python 3.x -municode is needed when building an executable which corresponds to the definition of wmain.