distributing linux binary along with liballeg.so-file
Frank Drebin

hi guys,

I found some threads about distributing linux binaries along with the liballeg.so-file in case you cannot/don't want to link allegro statically.

https://www.allegro.cc/forums/thread/613202
https://www.allegro.cc/forums/thread/589020

in these threads it seems that setting the LD_LIBRARY_PATH to use the liballeg.so-file that is distributed along with the binary just works fine.

however, if I create a binary called 'demo', put the 'liballeg.so.4.4' in a directory called 'lib' in the same directory and run the following script

#!/bin/sh
LD_LIBRARY_PATH=lib:$LD_LIBRARY_PATH ./demo

the binary still can't find the liballeg.so.4.4.

Do you have any ideas?

amarillion

I don't see anything wrong with your setup, it's pretty similar to how I've got things set up.

But maybe you can use the ldd tool to figure out where it's looking for shared libraries.

For example, here is the output of ldd on one of my games. You can see most of the libraries are found in /usr/lib, except for libdumb which I put in subfolder 'lib'.

ldd bin/usagi
  linux-vdso.so.1 =>  (0x00007ffec5da9000)
  libcurl.so.4 => /usr/lib/x86_64-linux-gnu/libcurl.so.4 (0x00007f7fba5dc000)
  libgtk-x11-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0 (0x00007f7fb9f91000)
  libgdk-x11-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0 (0x00007f7fb9cdb000)
  libgdk_pixbuf-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0 (0x00007f7fb9ab9000)
  libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f7fb9866000)
  libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f7fb9554000)
  libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007f7fb932f000)
  libjpeg.so.8 => /usr/lib/x86_64-linux-gnu/libjpeg.so.8 (0x00007f7fb90d6000)
  libFLAC.so.8 => /usr/lib/x86_64-linux-gnu/libFLAC.so.8 (0x00007f7fb8e60000)
  libdumb.so.1 => /home/martijn/prg/alleg/helixgames-submodules/usagi/bin/../lib/libdumb.so.1 (0x00007f7fb8c2c000)
  libvorbisfile.so.3 => /usr/lib/x86_64-linux-gnu/libvorbisfile.so.3 (0x00007f7fb8a23000)

Frank Drebin

that is the output of the allegro demo after compiling it with the shared library:

#SelectExpand
1$ldd demo 2 linux-gate.so.1 => (0xb775a000) 3 liballeg.so.4.4 => /usr/lib/i386-linux-gnu/liballeg.so.4.4 (0xb762a000) 4 libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb7474000) 5 libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb741e000) 6 libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb7401000) 7 librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xb73f8000) 8 libX11.so.6 => /usr/lib/i386-linux-gnu/libX11.so.6 (0xb72ad000) 9 libXext.so.6 => /usr/lib/i386-linux-gnu/libXext.so.6 (0xb7298000) 10 libXcursor.so.1 => /usr/lib/i386-linux-gnu/libXcursor.so.1 (0xb728c000) 11 libXpm.so.4 => /usr/lib/i386-linux-gnu/libXpm.so.4 (0xb7278000) 12 libXxf86vm.so.1 => /usr/lib/i386-linux-gnu/libXxf86vm.so.1 (0xb7271000) 13 libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb726c000) 14 /lib/ld-linux.so.2 (0x80000000) 15 libxcb.so.1 => /usr/lib/i386-linux-gnu/libxcb.so.1 (0xb7246000) 16 libXrender.so.1 => /usr/lib/i386-linux-gnu/libXrender.so.1 (0xb7239000) 17 libXfixes.so.3 => /usr/lib/i386-linux-gnu/libXfixes.so.3 (0xb7232000) 18 libXau.so.6 => /usr/lib/i386-linux-gnu/libXau.so.6 (0xb722e000) 19 libXdmcp.so.6 => /usr/lib/i386-linux-gnu/libXdmcp.so.6 (0xb7227000)

however, I want the game to run without allegro installed and to use liballeg.so.4.4 in the lib directory of the binary rather than looking for it in '/usr/lib/i386-linux-gnu'. Therefore, I copied liballeg.so.4.4 in a directory called lib that is located in the same directory as the binary and removed allegro completely.

Now if I run the script 'rundemo' containing

#!/bin/sh
LD_LIBRARY_PATH=lib:$LD_LIBRARY_PATH ./demo

it doesn't work. I attached the complete folder with the demo binary, liballeg.so.4.4 and the rundemo script so you can check it out.

amarillion

I think I see the problem. The file lib/liballeg.so.4.4 in your demo is not actually the library in question, but a symlink to liballeg.so.4.4.2, and that isn't included in the archive.

ls -la lib/liballeg.so.4.4 
lrwxrwxrwx 1 martijn martijn 17 Sep  3 16:28 lib/liballeg.so.4.4 -> liballeg.so.4.4.2

Make sure you have the correct library in lib. And read up on symlinks if that isn't entirely clear

By the way, you can override LD_LIBRARY_PATH also for ldd. But because of the broken symlink, that doesn't help here.

LD_LIBRARY_PATH=lib ldd ./demo 
  linux-gate.so.1 =>  (0xf775d000)
  liballeg.so.4.4 => not found
  libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf757a000)
  /lib/ld-linux.so.2 (0x5659c000)

Frank Drebin

Thanks so much amarillion now it works ;D

Well except for the sound... do I need to include another lib for this?

amarillion

For my allegro 5 games, I put libdumb in the lib folder to get music. But I don't remember how the situation was for allegro 4.4. What is the LDD output you get now? Maybe that will provide some clues.

Frank Drebin

[EDIT]

I found the solution here

It seems I also have to set ALLEGRO_MODULES to point to the directory lib and put all .so files (i.e. alleg-alsadigi.so, alleg-alsamidi.so, alleg-dga2.so, liballeg.so.4.4, liballeg.so.4.4.2) as well as modules.lst there.

then the following scripts works fine

#!/bin/sh
ALLEGRO_MODULES=lib LD_LIBRARY_PATH=lib ./demo

I figured out that the sound will work with only alleg-alsadigi.so and modules.lst. I am wondering if alleg-alsamidi.so and alleg-dga2.so should be included as well. What do you think?

Thread #617030. Printed from Allegro.cc