The Allegro Wiki is undergoing maintenance, please be patient.

Install Allegro5 From Git/Windows

From Allegro Wiki
Jump to: navigation, search

This guide will show how to compile Allegro5 version 5.2 from source on Windows using the MinGW compiler. Allegro has quite a few third-party dependencies, so this guide will also show you how to compile those.

Preliminaries

First, we need to install some tools and setup a development folder where you will download the sources for the dependencies and Allegro.

Development directory

  1. Create a development directory under the C drive called "devel" (i.e. you will have a directory C:\devel).

Dependency sources

Installation steps:

  1. Download the dependency sourcepack: File:A5 sourcepack.zip.
  2. Extract it into the development directory (C:\devel)

You will now have a directory (C:\devel\a5_sourcepack) that contains the sources of the various third party dependencies. After you are done with this guide, it is safe to delete it.

MinGW

MinGW will provide you with a C/C++ compiler and a MSYS shell that will be used to build some dependencies

Installation steps:

  1. Download and run the MinGW installer: http://sourceforge.net/projects/mingw/files/latest/download?source=files
  2. Select "Download latest repository catalogues" in the "Repository Catalogues" step
  3. Keep the installation directory unchanged ("C:\MinGW")
  4. Select the following components when prompted
    • C Compiler
    • C++ Compiler
    • MSYS basic system
  5. After the installation is complete, open the Command Prompt (Press Win+R, type "cmd" and press Enter) and enter the following command (this will allow the use of MinGW tools from the command line):
set path="C:\MinGW\bin;%path%"

CMake

CMake is used to build Allegro and some dependencies

Installation steps:

  1. Download and run the Win32 installer from http://www.cmake.org/cmake/resources/software.html
  2. Select "Add CMake to the system path for current user" in the "Install Options" step

Git

Git is a version control system necessary to fetch Allegro sources.

Installation steps:

  1. Download and run the latest installer from http://git-scm.com/downloads
  2. Select "Run git from the Windows Command Prompt" in the "Adjusting your PATH environment" step

Required Dependencies

Allegro5 has only a single required dependency, the DirectX SDK. Note that if you only install this dependency Allegro5 will be severely limited in what it can do, so you probably should install the optional dependencies as well!

DirectX SDK

??? Why are we advising the use of the FULL DXSDK?

Installation steps:

  1. Download and run the DirectX SDK installer from https://www.microsoft.com/en-us/download/details.aspx?id=6812
    • Note: This is a huge download... feel free to do the optional dependencies while the download completes!
    • Note: You might get an error during the installation (code S1023). Follow the directions at http://support.microsoft.com/kb/2728613 to resolve it.
  2. Deselect DirectX documentation, and DirectX samples and source code. You don't need them.
  3. Change the installation directory to C:\devel\DXSDK (if you have the option to do so)
  4. After the installation is complete, open the Command Prompt (Press Win+R, type "cmd" and press Enter) and enter the following command (this will install a missing header):
copy /Y C:\devel\a5_sourcepack\dxfixes\sal.h C:\MinGW\include\

As an alternative, you may download a minimal version of the DXSDK from liballeg.org here : dx9mgw.zip. It contains all the DX files you need to compile allegro with. Just extract into your mingw directory.

Optional Dependencies

These are the third-party dependencies that are necessary for Allegro5 to do the things it does. Some of these dependencies are built from the command prompt and some are built from the MSYS shell.

To launch the command prompt: Press Win+R and then type "cmd" (no quotes) and press Enter.

To launch the MSYS shell: Press Win+R and then type "C:/mingw/msys/1.0/msys.bat" (no quotes) and press Enter. Also on a modern Windows you can press Win, and type "MinGW shell" and press Enter.

Note: You don't need to launch a new command prompt or MSYS shell for each operation (except when building Allegro), you can just reuse the already opened shell for the relevant dependencies.

Note: You should install these dependencies in order they are presented here

Note: The Allegro5 README also lists OpenAL as a dependency in addition to those listed here.

ZLib

Required for: Image loading

Installation steps:

  1. Launch the Command Prompt and enter the following commands
cd C:\devel\a5_sourcepack\zlib
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=C:\MinGW -G "MinGW Makefiles"
mingw32-make install

LibPNG

Required for: Loading PNG images

Installation steps:

  1. Launch the Command Prompt and enter the following commands
cd C:\devel\a5_sourcepack\libpng
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=C:\MinGW -G "MinGW Makefiles"
mingw32-make install

LibJPEG

Required for: Loading JPEG images

  1. Launch the MSYS shell and enter the following commands
cd C:/devel/a5_sourcepack/jpeg
./configure --prefix=/c/mingw
make install

Freetype

Required for: Loading and displaying TrueType fonts

  1. Launch the MSYS shell and enter the following commands
cd C:/devel/a5_sourcepack/freetype
./configure --prefix=/c/mingw
make -i install

Note: FreeType's build system is very screwy and will probably tell you that there were some (ignored) errors. That is fine, it will still have installed correctly. The errors deal with some programs that are not necessary for Allegro.

LibOGG

Required for: Loading and playing OGG audio files

  1. Launch the MSYS shell and enter the following commands
cd C:/devel/a5_sourcepack/libogg
./configure --prefix=/c/mingw
make install

LibVorbis

Required for: Loading and playing OGG audio files

  1. Launch the MSYS shell and enter the following commands
cd C:/devel/a5_sourcepack/libvorbis
./configure --prefix=/c/mingw
make install

LibTheora

Required for: Loading and playing OGV video files. Allegro 5.1 only!

  1. Launch the MSYS shell and enter the following commands
cd C:/devel/a5_sourcepack/libtheora
./configure --prefix=/c/mingw
make install

FLAC

Required for: Loading and playing FLAC audio files

  1. Launch the MSYS shell and enter the following commands
cd C:/devel/a5_sourcepack/flac
./configure --prefix=/c/mingw  --disable-xmms-plugin --disable-cpplibs
make install

PhysFS

Required for: Loading files from compressed archives (e.g. .zip files)

Installation steps:

  1. Launch the Command Prompt and enter the following commands
cd C:\devel\a5_sourcepack\physfs
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=C:\MinGW -G "MinGW Makefiles"
mingw32-make install

DUMB

Required for: Loading and playing audio tracker files (e.g. .mod, .it etc)

Installation steps:

  1. Launch the Command Prompt and run
cd C:\devel\a5_sourcepack\dumb
mingw32-make MINGDIR=C:\MinGW
  1. Enter "M" to select MinGW and "N" to say no to Allegro support (they mean Allegro 4, which we are not interested in)
  2. Enter the following commands
mingw32-make install MINGDIR=C:\MinGW

Building Allegro

After you have installed of the dependencies, you can now build and install Allegro.

Installation steps:

  1. Launch a new Command Prompt and type these commands into the command prompt:
    cd C:\devel
    git clone https://github.com/liballeg/allegro5.git Allegro5
    cd Allegro5
    
  2. By default, the source you downloaded is for the latest release of Allegro (5.2). To make sure, type the following into the command prompt :
    git checkout 5.2
    
  3. Now we are ready to build Allegro. First, issue these commands:
    mkdir build
    cd build
    cmake .. -G "MinGW Makefiles"
    

    This will configure the build system to build the release version of Allegro with debug information. If you don't want that, issue these commands afterward:

    • For the debug version (useful to generate allegro.log)
      cmake .. -DCMAKE_BUILD_TYPE=Debug
      
    • For the release version without debug symbols (sometimes useful to conserve space)
      cmake .. -DCMAKE_BUILD_TYPE=Release
      
    • For the profiling version (you rarely need this)
      cmake .. -DCMAKE_BUILD_TYPE=Profile
      
    • For the default version
      cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo
      
  4. To build the monolithic version of Allegro, add the following to your cmake command :
    -DWANT_MONOLITH=On
    
  5. To build the static version of Allegro, add the following to your cmake command :
    -DSHARED=Off
    
  6. Build and install allegro by issuing this command:
    mingw32-make install
    
  7. Assuming there are no errors, this completes the installation. Have fun using Allegro 5!

Note: Occasionally CMake will get confused about things... if you think that is happening, delete the CMakeCache.txt file from the build directory (C:\devel\Allegro5\build) and repeat steps 2-4. Usually you don't need to do this.

Note: If you want to update Allegro to the newest version, follow these steps:

  1. Open up a Command Prompt and issue this command:
    cd C:\devel\Allegro5
    
  2. Check out the latest release branch (5.2) that you want to update:
    git checkout 5.2
    
  3. Now update the branch by issuing this command:
    git pull
    
  4. Now just repeat the Installation steps 2-4.