The Allegro Wiki is migrating to github at https://github.com/liballeg/allegro_wiki/wiki

Unix Issues

From Allegro Wiki
Jump to: navigation, search
Broom icon.png
This article or section is messy and needs some minor revision to bring it up to quality standards. Please help Allegro by editing it. When the article is formatted correctly, you may remove this tag.


Q. When I run my program in Linux/BSD/Whatever Unix I get this error Error while loading shared libraries: liballeg.so.4.2: cannot open shared object file: No such file or directory

A. Short answer: the os can't find the Allegro library. You have two options

Option 1. Add the path to the allegro library to a system wide place permanently.

$ sudo vi /etc/ld.so.conf
## Add /usr/local/lib here, or wherever liballeg.so is
$ sudo /sbin/ldconfig

If you don't know where Allegro is installed you can try to find it with

$ allegro-config --libs
-L/usr/local/lib -L/usr/lib64 -Wl,--export-dynamic -lalleg-4.2.3 -lalleg_unsharable

That first part, -L/usr/local/lib, is where Allegro is installed to.

Option 2. Set the path for loading dynamic libraries in your .bashrc

$ vi ~/.bashrc
## add this line
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

Long answer: Executables on *NIX OS's load the code into memory as well as any shared libraries that executable is linked with. Since the executable only lists the shared library by name and not path( liballeg.so instead of /usr/local/lib/liballeg.so ), usually, you have to specify which directories to look in for shared libraries.