Building allegro5 with addons from source on Windows

When I run my game with the precompiles dll's everything works fine, but when I run my game with the dll's I compiled from source I can't load any assets. Is this because I am missing some libraries used by these addons? How would I fix this? I don't have this problem when running my game on linux with the libs I compiled from source.

Edgar Reynaldo

Replacing DLLs is not recommended these days. There are often incompatibilities between them.

You should be checking for errors in allegro init routines. As well as checking to see if your assets are NULL upon loading.

If you don't init the image addon, it won't load any formats recognized by allegro. Same for the font and ttf addons.

Also, if those addons aren't enabled in the build, they won't be present in the binary.


I made some changes to the audio addon so I can play audio in reverse, how am I supposed to test this if I can't use my own compiled dll's?

I am checking for errors in allegro init routines but this is not the problem. The assets load fine with the precompiled dll's but the assets are returning NULL upon loading when I use my source compiled dll's.

Edgar Reynaldo

You can use your own dlls, but you have to compile against the changed headers.

When you built allegro, did the image and font and ttf addons build?


It generates allegro_image-5.2.dll and allegro_font-5.2.dll so I am assuming it does. I ran cmake with `cmake .. -G "MinGW Makefiles"` and got these error messages: so I assumed I am missing some dll's.

I just found this page: and downloaded the lastest version. I assume this is what I need to fix my problem but I am not sure what to do with these files.

I also just noticed that I am not generating allegro_ttf-5.2.dll

Edgar Reynaldo

The winpkg is a source package for dependencies that builds with cmake.

You need to build those first, and then specify them when you build allegro.

Use cmake-gui, not cmake. It will show you much much more than what you see with cmake alone.

If you need help, you can refer to the Allegro 5 compile guide in my sig. It uses a slightly different process though.

The messages saying X could not be found need to be fixed for the addons and support to build correctly. PNG not found, ZLIB, JPEG, etc....


After finally being able to compile I get the error "The procedure entry point inflateReset2 could not be located in the dynamic link library in allegro_image-5.2.dll" when I start my test program. Have you ever had this problem?

Edgar Reynaldo

Sounds like you linked to the wrong Zlib.


I was indeed linking to the wrong zlib, thanks. I think I did everything correctly, yet somehow I ended up with the exact same problem I stated in my first post. I am not sure what to do at this point.

Edgar Reynaldo

Well, don't worry, it could be other things as well.

Have you tried static linking let's save that for later...

Are you sure there aren't any incompatible dlls in your %PATH%?

Try moving your exe and assets and new dlls to a separate folder. Then open a cmd.exe window and cd to that folder. Now type cmd.exe again. In the new environment (which inherits everything else) type 'set path=' and hit enter. Now try to run your program from within that shell and see what happens. You can type exit at any time to return to your original environment. This is to test what happens when the %PATH% is empty. It means it should look in the current folder only.

Next, have you made sure your current working directory is set correctly? It gets set to the directory you run the program from, which means, it isn't necessarily the same one. See for details.

After that has been tried we can discuss static linking, to rule out bad linking.


There were no changes using the method you stated above, am also sure the active directory is set correctly before loading any assets because I had already fixed that issue before.

Edgar Reynaldo

All right that rules that out let's start from the beginning.

What compiler did you download and from where?

What version of the winpkg did you download? Did you build them from source?

Can you make a simple example program that demonstrates this?

And also, make sure you're building in debug mode. Important clues can be gained from the allegro.log file.


I managed to fix my problem by completely reinstalling MinGW. However, I am not generating allegro_ttf-5.2.dll because of a problem with freetype. I guess this isn't really a problem because I am not planning on changing anything the the font addon so I can just use the precompiled allegro_ttf-5.2.dll. :P

Edgar Reynaldo

When you build Allegro, under Freetype in CMake, check HAVE_ZLIB and HAVE_PNG or whatever it says there. Then it will pass the compile test and build.


Freetype 2.9 needs to build with libpng and zlib. Then when you are compiling Allegro 5 use cmake-gui to check off FREETYPE_ZLIB and FREETYPE_PNG are enabled. On MSYS just type cmake-gui .. from the build directory to make things easy. I followed Edgar's tutorial to compile my Allegro DLLs.

Thread #617735. Printed from