Linking allegro statically


I wrote a simple game to get into Allegro on my Arch Linux machine. It runs all fine, but now when I want to distribute the game to a friend (uses Ubuntu)
he doesn't happen to have the allegro lib installed. Either he installs it,
what I don't like or I embed the Allegro libs into my executable.

How do I link Allegro statically/ embed it into my executable so that it just runs without further dependencies?


I've never done it on Linux, but, on Windows, before you compile allegro, go into the cmakelists txt and find the SHARED flag. It is ON, make it OFF.

This will build a static link version of Allegro.


Ah, I see. I'm using the precompiled version of allegro provided by the Arch community repository which happens to be static.

I'll compile allegro myself then, thanks!


A better way would be to also distribute the .so file. I usually do something like this:
My game binary is called game.bin, and I distribute it along with a script called game:

LD_LIBRARY_PATH=`pwd` game.bin

And then I distribute game, game.bin and together in the same folder. Users can now simply run game and it works.


That's a cool way to do it!

Is there an advantage to distributing the .so other than the fact that you can replace the .so to update the game rather the the exe?

Thread #613202. Printed from