Preparing MinGW

Instructions on how to make MinGW link to msvcr71.dll and add MSYS's /usr/local directory to the search path are here.

Compiling zlib

From the zlib-1.2.3 directory:

sed 's/dllwrap/dllwrap -mwindows/' win32/Makefile.gcc >Makefile.gcc make IMPLIB='libz.dll.a' -fMakefile.gcc

The make install does not work properly:

cp -fp *.a /usr/local/lib cp -fp zlib.h /usr/local/include cp -fp zconf.h /usr/local/include

Optional:

make test -fMakefile.gcc make testall -fMakefile.gcc

Compiling libpng

From the libpng-1.2.19rc2 directory:

./configure --with-libpng-compat=no --disable-shared make

It will print some stuff about only building a static library because "linker path does not have a real file for library -z". That is OK since it is in /usr/local where gcc knows to look.

Remove a duplicate line in the def file:

sed '222 d' scripts/pngw32.def >in.def dlltool -D libpng13.dll -d in.def -l libpng.dll.a ranlib libpng.dll.a gcc -shared -s -mwindows -def in.def -o libpng13.dll .libs/libpng.a -lz

Only install the headers and import library, otherwise SDL_image will statically link to png.

cp png.h /usr/local/includep> cp pngconf.h /usr/local/include cp libpng.dll.a /usr/local/lib cp libpng13.dll /usr/local/bin

Compiling jpeg

From the jpeb-6b diretory:

./configure --disable-shared make CFLAGS='-02' dlltool --export-all-symbols -D jpeg.dll -l libjpeg.dll.a -z in.def libjpeg.a ranlib libjpeg.dll.a gcc -shared -s -mwindows -def in.def -o jpeg.dll libjpeg.a

Only install the headers and import library, otherwise SDL_image will statically link to jpeg.

make install-headers cp libjpeg.dll.a /usr/local/lib cp jpeg.dll /usr/local/bin

Optional:

make test

Compiling libtiff

From the tiff-3.8.2 directory:

./configure --disable-cxx --prefix=/usr/local --disable-shared make cd libtiff gcc -shared -s -mwindows -def libtiff.def -o libtiff.dll .libs/libtiff.a -ljpeg -lz dlltool -D libtiff.dll -d libtiff.def -l libtiff.dll.a ranlib libtiff.dll.a

Only install the headers and import library, otherwise SDL_image will statically link to libtiff.

make install-data-am cp libtiff.dll.a /usr/local/lib cp libtiff.dll /usr/local/bin

Compiling SDL

First delete the following three lines from the files

SDL-1.2.12\src\video\windx5\directx.h and SDL-1.2.12\src\audio\windx5\directx.h. #ifdef __GNUC__ #define NONAMELESSUNION #endif

This fixes these outdated headers. Now from the SDL-1.2.12 directory:

export LDFLAGS="-mwindows" ./configure make install

Compiling libogg

From the libogg-1.1.3 directory:

export LDFLAGS='-mwindows' ./configure make install

Compiling libvorbis

From the libvorbis-1.2.0 directory:

export LDFLAGS='-mwindows' ./configure make LIBS='-logg' install

Compiling smpeg

From the smpeg directory:

./autogen.sh

In the following step you can add MMX support with the --enable-mmx option.

./configure --disable-gtk-player --disable-opengl-player --disable-gtktest make CXXLD='$(CXX) -no-undefined' install

Compiling SDL_mixer

You'll also need to export INCLUDE="" for this... otherwise the configure script doesn't work.

export INCLUDE="" ./configure --disable-music-ogg-shared --disable-music-mp3-shared make install

Compiling SDL_image

Dynamic loading of support libraries is disabled so that the DLLs in the pygame package directory are used.

./configure --disable-jpg-shared --disable-png-shared --disable-tif-shared make install

Compiling freetype

The freetype Makefile will not build a shared library. But since SDL_ttf is the only DLL that uses it then freetype can statically linked in. To compile the static library go to the freetype-2.3.5 subdirectory and do:

./configure make install

Compiling SDL_ttf

SDL_ttf is the only library that builds without a hitch. So simply do:

./configure make install

Building Pygame without Msys

To build Pygame with MingW but without Msys the dependencies are expected to be in the subdirectory prebuilt. Prepare prebuilt as follows. Copy /usr/local as the prebuilt subdirectory of the pygame directory. Next go into prebuilt\include and move all the header files in SDL and libpng12 into include so the compiler will find them. Now you are ready to execute setup.py from a normal command prompt, assuming the MINGW_ROOT_DIRECTORY environment variable is set and the gcc binaries are in the executables search path:

python setup.py build --compiler=mingw32