allegro 4.0.1+5.2.0

D binding to the Allegro5 game development library

To use this package, put the following dependency into your project's dependencies section:


This is a D1.0 and D2 binding to the Allegro 5 library:

Should work fine with Allegro 5.2. Pretty much all of the cross-platform functions are bound. Non cross-platform functions are absent, but they will be added eventually.

Tested with LDC/Tango and DMD/Phobos compilers on Linux 64 bit and DMD/Tango on Windows 32 bit (XP). See general notes below to see how to use this binding in your D program.


You have two options here. You can copy all the modules into your project, and just use them like that. Alternatively, you can compile the binding into a static library for convenience:


If you have LDC:

./ ./

If you have LDC2:

./ ./

If you have DMD:

./ ./


If you have MinGW compiled libraries (< 4.6):


If you have MSVC/DMC compiled DLLs:

buildlibdmd.bat -version=ALLEGRO_MSVC

Compiling the example


If you have LDC:


If you have DMD:


Try the example by running:


It should run and not crash.



Try the example by running:


It should run and not crash.

Unstable API

If you want to use the unstable API, set the ALLEGRO_UNSTABLE version.

General Notes

Using Allegro in a D program is a little bit different than using it in a C/C++ program. Specifically, you must run your code through the alrunallegro function like so:

import allegro5.allegro;

void main()
		//your code goes here
		return 0;

alrunallegro will block until your code returns. On some platforms it will run your code in a different thread (you generally don't need to worry about this). This is done for cross-platform (specifically OSX) compatibility. Note that alinit/alinstallsystem should be called inside the delegate you pass to alrun_allegro.

This binding is equipped with pragma(lib) constructs that should allow you to not have to specify which Allegro libraries to link to. It only works this way in D2, however. It expects libraries to be named the same way they are named by the build process or generated by the import library generator script (Windows only). Monolith libraries are not supported. This mechanism can be overriden by using the version ALLEGRONOPRAGMA_LIB.

The module allegro5.dutil contains some utility functions for converting between D strings and ALLEGROUSTR.

Windows Notes

  • You will need to generate the import libraries for Allegro's dll files using implib.exe that you can download here:

    You can then use the createimportlibs.bat to create the import libraries. The script expects the Allegro DLLs to be in the same directory as the script. It also expects the implib to be callable from the command line (place it in PATH or into the directory alongside the script). E.g. if your directory had these DLL's in it:

    allegro-5.2.dll allegro_primitives-5.2.dll

    Running the script will produce these import libraries:

    allegro.lib allegro_primitives.lib

    If you're using dmd then when compiling you must pass the following linker flags to it for things to work properly:


    If you want console output (this will also spawn the console whenever you run the program outside the command prompt) then use these flags:


  • Note that if you are using MSVC or DMC compiled DLLs you will need to set the version to ALLEGRO_MSVC when compiling your own programs as well as when building the library.

  • You can obtain pre-built libraries at

Authors: SiegeLord

Dependencies: none

4.0.1+5.2.0 2016-Oct-01
4.0.0+5.2.0 2016-May-07
3.0.2+5.1.13 2016-Feb-01
3.0.1+5.1.8 2015-Apr-04
3.0.0+5.1.8 2014-Sep-14
Show all 12 versions
  • 5 downloads today

  • 6 downloads this week

  • 13 downloads this month

  • 581 downloads total