Creating a 64 bit development environment with MinGW on Windows - darkopevec/kivy GitHub Wiki

DEPRECATED: Kivy wheels using mingwpy are available since 1.9.1. It is recommended that https://binstar.org/carlkl/mingwpy be used instead of generic MinGW.

In order to use kivy in true 64 bit mode you'll first need to set up your environment to be able to build 64 bit binaries. For this you'll need the 64 bit mingw. We'll assume that you already installed a 64 bit Python into e.g. C:\dev-64\python27:

  1. Download the mingw 64 binaries (e.g. x86_64-4.8.2-release-win32-sjlj-rt_v3-rev0.7z) from e.g. the personal builds at http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.8.2/threads-win32/sjlj/. Now extract the zip file into C:\dev-64. Rename the top level directory, if it's not already, to mingw64. You should now have the following directory structure:

    C:\dev-64\mingw64\bin
    C:\dev-64\mingw64\include
    C:\dev-64\mingw64\mingw
    ...
    

    where C:\dev-64\mingw64\bin contains e.g. gcc.exe etc.

  2. You'll need gendef. Download and extract gendef.exe into mingw64/bin from http://sourceforge.net/projects/mingw/files/MinGW/Extension/gendef/gendef-1.0.1346/. Keep in mind that this is a 32 bit binary.

  3. At this point it's helpful to use the kivy.bat file and to edit the python paths to point to the proper Python27 location and to add the mingw64bin directory to the system path. In any case, for the following to work you either have to provide the full path to gendef and dlltool or add mingw64\bin to the system path.

  4. From C:\windows\system32 copy the file python27.dll into C:\dev-64\Python27\libs. Now type the following as described here http://bugs.python.org/issue4709:

    cd C:\dev-64\Python27\libs
    rename python27.lib old_python27.lib
    gendef python27.dll
    dlltool --dllname python27.dll --def python27.def --output-lib libpython27.a
    
  5. Now we'll patch the C:\Python27\include\pyconfig.h file. In that file search for the text #ifdef _WIN64, which in our copy of this file was at line 141, and cut out the following three lines:

    #ifdef _WIN64
    #define MS_WIN64
    #endif
    

    Search for the text #ifdef _MSC_VER, which in our copy of this file was at line 107. Paste in the cut-out lines, ABOVE the #ifdef _MSC_VER.

  6. Finally, we need to patch the cygwin compiler in distutils as described here http://bugs.python.org/issue16472. Open C:\dev-64\Python27\Lib\distutils\cygwinccompiler.py and comment out the line that says self.dll_libraries = get_msvcr(). In our file it's line 343. Be carefull because there's another similar line that does not need to be commented out.

You should now have a working 64 bit mingw installation and are ready to continue at step 2 of Using Kivy with an existing Python installation on Windows (64 or 32 bit). Just remember in step 3 to add mingw64\bin to the path instead of MinGW\bin.

⚠️ **GitHub.com Fallback** ⚠️