The Allegro Wiki is undergoing maintenance, please be patient.

Building with msys2

From Allegro Wiki
Jump to: navigation, search


The following guide explains how to set up MSYS2 minimal system on Windows and use the already available MinGW compiled dependencies to build Allegro 5 from source from the command line.

Required Downloads

You will need to download the MSYS2[1] package and this has to be unzipped in a directory of choice, to do this you can use for example the excellent 7-zip

MSYS2 archives can be found on sourceforge

  • here for the 64 bits version (x86_64)
  • here for the 32 bits version (i686)

choose the one matching your Windows system.


Download the most recent msys2-base-XXXXXXXX.tar.xz archive in the location provided in the previous chapter, unpack it and put it somewhere you're comfortable with.

  • Note: it is always a good measure to select a PATH with no spaces in it to avoid the most common problems.

Let's say in this example you put it in C:\msys, ending up with it installed in C:\msys\msys64 root directory.

It should look something like this inside:

07/05/2014  13:09    <DIR>          .
07/05/2014  13:09    <DIR>          ..
28/02/2014  16:49               167 autorebase.bat
09/05/2014  23:32    <DIR>          bin
04/04/2014  22:35    <DIR>          dev
06/05/2014  21:59    <DIR>          etc
04/04/2014  22:35    <DIR>          home
06/05/2014  21:59    <DIR>          include
06/05/2014  21:59    <DIR>          lib
02/02/2014  20:57             1.099 mingw32_shell.bat
02/05/2014  22:57    <DIR>          mingw64
02/02/2014  20:57             1.099 mingw64_shell.bat
02/02/2014  20:57            37.758 msys.ico
02/02/2014  20:57             1.096 msys2_shell.bat
06/05/2014  21:59    <DIR>          sbin
06/05/2014  21:59    <DIR>          share
06/05/2014  21:48    <DIR>          ssl
10/05/2014  22:41    <DIR>          tmp
04/04/2014  22:29    <DIR>          var

Run msys

Tu run MSYS2 you can use any of the mingwXX_shell.bat you have in the installation folder, use the 64 or 32 version depending on the MinGW compiler you will use.

For the sake of this guide we will assume you're working on a 64-bit system and thus will launch mingw64_shell.bat

  • Note: usually the first time you run MSYS2 shell you'll be asked to exit immediately, do so either closing the window or by tiping exit on the MSYS2 prompt.

It could also come handy to create a shortcut to this batch file, and place it on your desktop for easy retrieval.

Getting the tools to do the job

First of all a word of premise, MSYS2 uses a port of Arch Linux's pacman[2] to manage packages for the distribution.

This is indeed a very powerful and convenient way to get all the tools (compiler, make, cmake, dependiecies) you need to get allegro compiled from source.

First of all you need to sync the database with the latest repository, on the command line type:

 pacman -Sy

and the program should update (if need there should be) the local databse to the three online repositories (msys2, mingw64 and mingw32)

  • IMPORTANT NOTE: if you intend to use the 32-bit version of MinGW-gcc, you need to susbstitute EACH occurrence of 'x86_64' in the following instructions with 'i686'

Then, we need our compiler, binutils and all the stuff that come with gcc...

 pacman -S mingw-w64-x86_64-gcc
 pacman -S mingw-w64-x86_64-gdb # ability to debug is always useful

...will install a fair number of packages that will give you the 64-bit flavor of the latest stable GCC compiler and tools.

Then we need git source control management to (later) get the Allegro sources, and the latest cmake development version to (later) set up the building stage, and last the ubiquitous make to actually build Allegro.

 pacman -S git
 pacman -S make                         # this is MSYS2 make, also part of 'base-devel' group                           #
 pacman -S mingw-w64-x86_64-cmake       # cmake is fine, earlier versions of this guide recommended cmake-git to automatically find Freetype #
 pacman -S mingw-w64-x86_64-pkg-config  # optional, but could be useful with cmake                                      #

This should be all you need to get allegro to compile, next are the dependencies.

Install dependencies

Inside the shell, type these commands:

pacman -S mingw-w64-x86_64-freetype   # required for truetype font loading
pacman -S mingw-w64-x86_64-physfs     # also installs zlib and bzip2 - required for Loading files from compressed archives
pacman -S mingw-w64-x86_64-libvorbis  # also installs libOGG, required for OGG Audio playback
pacman -S mingw-w64-x86_64-flac       # required for FLAC audio playback
pacman -S mingw-w64-x86_64-dumb       # required for audio tracker files (e.g. .mod, .it etc)
pacman -S mingw-w64-x86_64-libtheora  # required for Video Playback - ALLEGRO 5.1 only       
pacman -S mingw-w64-x86_64-libjpeg-turbo

These are all the dependencies needed to have a full working Allegro 5.1 library built on Windows

Download Allegro Sources from git repository

Type the following command to retrieve the master branch of Allegro Sources

git clone

This will create a folder called allegro with the Allegro Source inside.


Allegro build is a two steps procedure:

1. First you need to issue a cmake command to have the build system set up the necessary makefiles; usually cmake is used with out of source build, meaning you create a specific folder to build into.

Like so:

 # outside of the 'allegro' folder #
 mkdir build_allegro_monolith
 cd build_allegro_monolith
 cmake \
	-G"MSYS Makefiles" \
	-DCMAKE_INSTALL_PREFIX=/mingw64/x86_64-w64-mingw32 \

The previous cmake command set the build for the monolith version of the library along with all Allegro examples and demos

If you receive errors relating to CMake such as Could NOT find DINPUT (missing: DINPUT_INCLUDE_DIR) it's likely CMake isn't resolving the directx headers and libraries. These are included in msys.

Try passing an altered PATH variable by replacing cmake with PATH=/mingw64/x86_64-w64-mingw32:$PATH cmake or PATH=/mingw32/i686-w64-mingw32:$PATH cmake in the above install line.

2. Then you issue the make command to actually build the sources, and then install them in the default location (should be '/mingw64' in the MSYS2 environment).

 # inside the 'build_allegro_monolith' folder #
 make && make install

Now you should have the headers as well as the monolith library installed within you compiler standard search path.

This means '#include' statements will be automatically resolved by the preprocessor and that you have to pass the '-lallegro_monolith' flag to the linker to build any Allegro application.

You're now ready to use Allegro5, have fun with it and feel free to drop by forums if you need any help.