Allegro.cc - Online Community

Allegro.cc Forums » Installation, Setup & Configuration » [A4, Linux] Bundling A4's audio .so files with game

This thread is locked; no one can reply to it. rss feed Print
[A4, Linux] Bundling A4's audio .so files with game
SimonN
Member #8,272
January 2007
avatar

Hi,

I want to bundle the shared objects of Allegro 4.2 or 4.4 with a game, so people don't have to install the lib to their system first. (Static linking doesn't solve the problem, see last paragraph.)

I made fine progress with liballeg-4.2.2.so respective its symlink liballeg.so.4.2. I put those in ./bin/lib, with . being the game's root directory, and linked like so:
ld -L./bin/lib -lalleg-4.2.2 -Wl,-rpath,./bin/lib *.o

The game finds the lib at runtime, plays normally, but sound will not work. Apparently, I also need the shared objects usually installed in /usr/lib/allegro/4.2.2, i.e. things like alleg-alsadigi.so, alleg-dga2.so, ..., modules.lst. I had no luck whatsoever with putting them in subdirectories of the game. Neither ./bin/lib/allegro/4.2.2 seemed to work, nor ./bin/lib, nor anything else.

ldd gameexecutable won't even display a need for these libs, unlike for the main A4 lib. Apparently Allegro does some magic in locating them, or just assumes a normal installation.

This also sheds light on (but not solves) this: If you build the static version of Allegro 4, link (statically) against it, and don't install any Allegro-related files into the system, sound will not work. Old topic with this issue: http://www.allegro.cc/forums/thread/608589

-- Simon

Arthur Kalliokoski
Second in Command
February 2005
avatar

I just checked my system, and there are no static libraries for ALSA.

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

― Robert A. Heinlein

SimonN
Member #8,272
January 2007
avatar

Same here, building the static liballeg.a will still make shared objects for ALSA etc.

The problem is how to place these shared objects in the game's tree.

-- Simon

Arthur Kalliokoski
Second in Command
February 2005
avatar

You might be able to do it if you recompile ALSA for a static library, but

Quote:

Due to bug in libtool script it is no longer possible to build shared and static libraries together.

http://www.linuxfromscratch.org/blfs/view/svn/multimedia/alsa-lib.html

That's more work than I want to mess with.

“Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”

― Robert A. Heinlein

Peter Wang
Member #23
April 2000

Set the ALLEGRO_MODULES environment variable in a shell script then launch your executable.

SimonN
Member #8,272
January 2007
avatar

Peter Wang: Perfect, thanks! This did it.

I read your A4 source (src/unix/umodules.c) to get the exact details right. For other people who might want to do this:

1. Do everything I wrote in the original post. (Linking statically didn't work for some reason with steps 2 + 3 here.)
2. Put the contents of /usr/lib/allegro/4.2.2/ into a subdir of the game. I used (gamedir)/bin/lib/allegro/, but anything is fine. Make sure you take all the files, including modules.lst.
3. Run the game with this shellscript:

#!/bin/sh

if [ ! -e bin/gameexecutable ]; then
    echo "This script should be run from the game's root dir."
    exit
fi

export ALLEGRO_MODULES=bin/lib/allegro
bin/gameexecutable

Basically, make sure you point ALLEGRO_MODULES to the exact relative directory in which modules.lst resides.

-- Simon

Go to: