Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » Linking allegro statically

This thread is locked; no one can reply to it. rss feed Print
Linking allegro statically
Wizzlebach
Member #15,290
August 2013

Greetings,

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?

jmasterx
Member #11,410
October 2009

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.

Wizzlebach
Member #15,290
August 2013

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!

Elias
Member #358
May 2000

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 liballegro-monolith.so together in the same folder. Users can now simply run game and it works.

--
"Either help out or stop whining" - Evert

jmasterx
Member #11,410
October 2009

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?

Go to: