How to load PNGs with Allegro using Dev C++

First step: download all the necessary DevPaks from Search and install them in the next order:

Download them and install them through Tools->Package Manager->Install.

Next, you have to check that DevC++ added the necessary command line options for the linker. Go to Project->Project Options->Parameters. In the third list, the linker arguments should include this one:


If it is not there, add it at the very end (including the hyphen).

Next, you have to add two libraries for the linkings. In my computer, they are located inside the lib directory of my DevC++ directory. Press the button “Add library or object” and look for these two files:



Also be sure that all the compilation command has the necesarry arguments to load Allegro, like -lalleg_s. This is my whole linker line, for example:

-lalleg_s -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lole32 -ldinput -lddraw -ldxguid -lwinmm -ldsound -lalpng

Here’s an example of a working piece of code, using an image file called image.png (with transparency) and including two libraries, allegro and alpng:

#include <allegro.h>
#include <alpng.h>

int main()
set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 800, 600, 0, 0);
img = load_png("image.png", NULL);
set_alpha_blender(); //this is important
draw_trans_sprite(screen, img, 0, 0); //this is important
return 0;


One thought on “How to load PNGs with Allegro using Dev C++

  1. Tom says:

    Win. Thanks ­čśŤ

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: