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 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.
|SDL 1.2(.13) revision 4114 from SVN||svn co -r 4114 http://svn.libsdl.org/branches/SDL-1.2|
|libpng 1.2.32||PNG reference library: libpng at SourceForge.net|
|freetype 2.3.7||The FreeType Project at SourceForge.net|
|FLAC 1.2.1||flac-1.2.1-src.tar.gz at SourceForge.net|
|SDL_mixer (1.2.8) revision 3942 from SVN||svn co -r 3942 http://svn.libsdl.org/trunk/SDL_mixer SDL_mixer-1.2|
|smpeg revision 370 from SVN||svn co -r 370 svn://svn.icculus.org/smpeg/trunk smpeg|
|PortMidi release 82||portmidi-src-82.zip at SourceForge.net|
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.
|GCC Version 3||gcc-core-3.4.5-20060117-3.tar.gz|
|MinGW API for MS-Windows||w32api-3.12-mingw32-dev.tar.tz|
|MSYS Base System||MSYS-1.0.10.exe|
|MSYS Supplementary Tools||msysDTK-1.0.1.exe|
|NASM Win32 binaries||nasm-2.05rc6-win32.zip|
MinGW and MSYS files are at MinGW - Minimalist GNU for Windows at SourceForge.net. NASM, The Netwide Assembler, is also at SourceForge.net. The DirectX headers, directx-devel.tar.gz, required to build the SDL library are at libsdl.org.
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.
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.
python msys_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.
python msys_build_deps.py SDL Z FREETYPE FONT PNG JPEG
python msys_build_deps.py TIFF IMAGE SMPEG OGG VORBIS MIXER
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.
Next, replace the libraries with msvcr90.dll linked versions.
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.
python setup.py build --compiler=mingw32 install
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.
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.)
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.
msys_build_deps.py 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.