Skip to content

Getting Started with MinGW on Windows

Ashley Davis edited this page Jul 9, 2015 · 4 revisions

Windows can be notoriously tricky to get started with. The following however should do the trick for a fresh install of MinGW; tested on Windows 8 but should work on any recent version.

NOTE: If you already have a MinGW installation you're on your own; you might want to consider backing up your existing install and just following the below anyway. If you want to compile with Visual Studio, please do give it a go and get back with how it went; it's probably best to compile with Visual Studio on Windows but it's not officially supported (yet!).

Installation

The best way to install MinGW is really to install a distro maintained by someone else. An excellent choice with most of the stuff you need is at nuwen.net. Follow the instructions there to install the latest version of g++. When you've got it installed (to C:/MinGW) run C:/MinGW/open_distro_window.bat.

The distro includes SDL2 and SDL2_mixer but is missing SDL2_image, SDL2_ttf and tmxparser (as well as the tmxparser dependency "tinyxml2")

Installing Dependencies

Mainly you need to make sure the libraries end up in /MinGW/lib, the includes in /MinGW/include and the binaries in /MinGW/bin. Note that the default "make install" installs to your Program Files (x86) directory (assuming you have admin)

When running cmake you'll probably need to define -DCMAKE_PREFIX_PATH=/MinGW.

  • SDL2_image
    Binaries available for mingw here; be sure to copy the x86_64 versions. No need to build.

  • SDL2_ttf
    As with SDL2_image, just extract and copy paste.

  • TinyXML2

git clone git@github.com:leethomason/tinyxml2.git
mkdir build && cd build
cmake -G "Unix Makefiles" -DCMAKE_PREFIX_PATH=/MinGW ..
make && make install # and copy paste to /MinGW
git clone git@github.com:andrewrk/tmxparser.git
mkdir build && cd build
cmake -G "Unix Makefiles" -DCMAKE_PREFIX_PATH=/MinGW -DZLIB_LIBRARIES=/MinGW/lib/libz.a ..
# we define the zlib library specifically because MinGW can get confused if it finds a zlib dll on the PATH
make && make install # and copy paste to /MinGW

Note: The tmxparser dll might appear in the lib folder after installation; you'll have to copy this manually to bin.

  • SDL2
    While SDL2's development libraries do come installed, you might need to download a DLL to actually run the examples/your applications. This can probably be found on the SDL2 site above.

Compiling APG

Just compiling the library should go smoothly if you've set up your dependencies correctly. It should be as simple as:

cd APG
mkdir build && cd build
cmake -G "Unix Makefiles" -DCMAKE_PREFIX_PATH=/MinGW
make

Running applications linked against APG might need DLLs that were compiled in the above step; if upon running an example you get a message about missing DLLs you can probably find it in C:\MinGW\bin and copy-paste.

For compiling your own application with APG, you'll probably need to link against some windows specific libraries; check in CMakeLists.txt for a list of the libraries. A possibly-not-exhaustive list is: Version Imm32 winmm vorbisfile ogg vorbis mingw32. You'll likely also want to pass -mwindows as a compiler argument.

Clone this wiki locally