Creating a 64 bit development environment with MinGW on Windows

matham edited this page Nov 30, 2015 · 2 revisions

DEPRECATED: Kivy wheels using mingwpy are available since 1.9.1. It is recommended that 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 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:


    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 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

    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

    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 Open C:\dev-64\Python27\Lib\distutils\ 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.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.