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 msys_build_deps.py 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 msys_build_deps.py exclude option -e.

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

building the dependencies

Dependencies are built using the msys_build_deps.py 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.

pythonmsys_build_deps.py--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.

pythonmsys_build_deps.pySDLZFREETYPEFONTPNGJPEG

pythonmsys_build_deps.pyTIFFIMAGESMPEGOGGVORBISMIXER

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 msys_build_deps.py. Next create the prebuilt directory and copy the libraries and headers to it.

pythonmake_prebuilt.py

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

msys_link_VC_2008_dlls.py

Finally run config.py, 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 setup.py script. Everything can be done in one step.

pythonsetup.pybuild--compiler=mingw32install

The first time setup.py 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 msys_build_deps.py. 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.

additional links

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