Skip to main content

MingW — wiki

Due to g++/VC++ incompatibilities, MinGW support is unavailable for Pygame 1.9.2

These instructions are for Pygame 1.9.0, revision 1673 and up. For earlier Pygames, 1.8.0 and 1.8.1, look at the document string for the list of relevant Pygame dependency versions and Msys/MinGW build tools.

Note that a source bundle and precompiled binaries of the Pygame 1.8 dependecies are available on the download page.

pygame dependencies on windows

This list of libraries shows the version tested with Pygame 1.8 as well as a link to the actual source bundle used. *note* We should have a download with everything included. As well as patches for each one that we need.

Choose, or create, a directory having a path with no spaces in it (Some library build scripts, and Msys's mount, fail when spaces are present.) Place all the dependency source code directories, along with the Pygame SVN trunk directory, in the directory. All build steps will be done from the Pygame trunk directory, where the necessary scripts are located.

Note that FLAC or ogg-vorbis audio support is not necessary for Pygame to function. The relate libraries can be omitted from the SDL_mixer build by using the exclude option -e.

build tools

GCC Version 3 gcc-core-3.4.5-20060117-3.tar.gz
GNU Binutils binutils-2.17.50-20060824-1.tar.gz
MinGW Runtime mingwrt-3.15.1-mingw32-dev.tar.gz
MinGW API for MS-Windows
GNU Make mingw32-make-3.81-20080326-3.tar.gz
MSYS Base System MSYS-1.0.10.exe
MSYS Supplementary Tools msysDTK-1.0.1.exe
NASM Win32 binaries
DirectX headers directx-devel.tar.gz

MinGW and MSYS files are at MinGW - Minimalist GNU for Windows at NASM, The Netwide Assembler, is also at The DirectX headers, directx-devel.tar.gz, required to build the SDL library are at

Add the DirectX headers in the tar.gz include director to the MinGW include directory. These are for the older DirectX 5 and do not conflict with those included with the win32api. Also NASM can go with the MinGW binaries.

python requirements

To build the dependencies Python 2.4 or newer and pywin32 are required.

building the dependencies

Dependencies are built using the script found in the root Pygame source directory. Though it requires MinGW and Msys it can be run from the Windows DOS prompt. The program is thoroughly documented with a command line --help option and module level doc string. The following command will build the dependencies and link them to msvcr71.dll.

python --all

On a 2007 dual core Pentium computer, 1 Gb. memory, Windows XP, the build takes about thirty minutes. For an older computer it may not be possible to build everything in one step due to a known Msys problem. In this case the build can be split into two or more steps.


It is best to reboot the computer between steps.

Python 2.6 dependency instructions

Python 2.6 is compiled with Visual C++ 2008 on Windows. This means the corresponding C runtime library, msvcr90.dll, is a side-by-side installation dependent on manifests. To get around this the dependencies are built against another C runtime, msvcrt.dll or msvcr71.dll, and the static library versions converted to DLLs that are placed in a prebuilt directory.

So the first step is to build the dependencies as normal with Next create the prebuilt directory and copy the libraries and headers to it.


Next, replace the libraries with msvcr90.dll linked versions.

Finally run, answering n to Is this an mingw/msys build [Y/n]: and y to Use the SDL libraries in "prebuilt"? [Y/n].

building and installing pygame

Pygame itself is built and installed using the distutils script. Everything can be done in one step.

python build --compiler=mingw32 install

The first time is run it creates a Setup file which specifies the modules to build. When it does it may prompt for additional information.

making prebuilt directories

Two DOS batch files, MakePrebuilt71.bat and MakePrebuilt90.bat, are provided to assemble a prebuilt directory from the dependencies left in the Msys /usr/locals directory by Requirements are pexports (found in altbinutils-pe at SourceForge) and some version of Visual Studio or Visual C++ Toolkit (for building VC import libraries). Python, pexports and VCVARS32.BAT must also be on the executable search path.

building by hand

The older instructions for hand building the dependencies are here. These go back to Pygame 1.8.0 and so are outdated.

Simple Direct Media (SDL) home page

Minimalist GNU for Windows (MinGW) home page

Compiling python extensions at the MinGW Wiki. (Note 05/20/2010: MinGW Wiki has moved to here. Compiling Python Extensions has been moved to the FAQ, see topic Other: How do I create Python Extensions. At the top of the FAQ page there is a link to the old wiki, which has also changed addresses.)

SDL build instructions for Tux Paint.

vista notes

Seems the Msys install crashes... so when it does, open the cmd prompt and run the command that failed. For me it was the postinstall command. does have a command line option, -m <msys root directory path>, for specifying the msys directory.

So Msys need not be full installed with a registry entry.

But Msys will still have to be hand configured for MinGW. To do that make sure there is an msys\1.0\etc\fstab file with the line c:/mingw /mingw in it.

Of course replace c:/mingw with the correct MinGW root directory path if it differs. Using forward slashes in the path is necessary.