How do you make using the allegro library simple for the user ?


I almost finished writing my game, and now I'm focusing on testing it on other machines than mine. So I'm wondering how do you handle the allegro library in your projects for the users.

For now the user has to independently install the library himself, but I'd like to make it simpler. Is there a way to make an automated installation ? I'm thinking shell script, or maybe in the makefile, but I don't know if that's the best way to do it. Or maybe to turn the library static to just have a single executable at the end ?

What do you think is the best way ?

Edgar Reynaldo

You can either link dynamically and distribute the allegro dlls with your program, or you can link statically and create a stand alone executable.


Do you know how to statically link allegro on linux, or maybe have a resource on the subject ? I'm kind of a noobie on the all linking thing.

Edgar Reynaldo

On linux, you use pkg-config calls.

g++ -Wall -O2 -o proggie `pkg-config --cflags --static allegro_monolith-5` proggie.cpp `pkg-config --libs --static allegro_monolith-5`


I'm using C, but I guess the command is the same with gcc isn't it ?

Also I can't find the monolith version of the library. Do I have to recompile allegro myself ?

Edgar Reynaldo

It depends on where you got allegro from. The monolith is just much easier in my opinion.

Otherwise you have to list every addon you use every time you call pkg-config, which sucks.

Where did you get Allegro? You're using 5 right?


Yes I have allegro 5, and I do list every package in the gcc command (you're right, that was a pain, but since I use a makefile, it doesn't matter much).

I installed it by following the debian tutorial here.

EDIT: I used your command but linking every addon instead of the monolith, and tried to execute the file on a another computer without allegro, but it didn't work.

It gave me this error:

./tetris: error while loading shared libraries: cannot open shared object file: No such file or directory

It still is dynamically linked, which I'm guessing is because I only have the .so versions of the library and the source.
Also, I tried to recompile allegro with "-DWANT_MONOLITH=on" to get the monolith version, but it was just ignored by cmake.

Edgar Reynaldo

Try putting --static before --libs. And if that fails, try putting "-static" before pkg-config linker command.

`pkg-config --static --libs allegro_monolith-5`

However, static linking on Linux is a nightmare. The one thing Linux fails at is portability.


Ok thanks, I managed to rebuild allegro to get the static linux files (with the cmake option -DSHARED=off).

You were right, it wasn't easy and "out of the box", and there are still dependencies like libpng and libjpeg I had to install on the other machine, but it works.

Edgar Reynaldo

If you rebuild them (libpng and libjpeg and zlib) as static and then rebuild allegro properly, they should disappear.

Thread #617169. Printed from