Linux newbie - symbol lookup error?
Craig Harrison

Well, I just installed Linux (Fedora Core 6) for the first time and am learning how it all works (so remember... talk dumb). Anyway, I have installed allegro, can compile stuff and everything, but when I go to run any program it gives me this error. This is with the exhello example, but it does it with everything.

[root@localhost examples]# ./exhello
./exhello: symbol lookup error: ./exhello: undefined symbol: _install_allegro_version_check

Being a Linux newbie, I have no idea what to do. Any help would be appreciated!

kazzmir

Well first of all Id say dont compile and run things as root. Only use root to install things and then only use 'sudo', not 'su'.

I vaguelly recall seeing that error before but can't quite remember what it was about. I think you are running with a different version of allegro than you compiled with. Did you install Allegro yourself? If you run these two commands what do you see?

$ ls /usr/lib/liballeg*
and
$ ls /usr/local/lib/liballeg*

Peter Wang

You will get this error if you have a program compiled with 4.2.1, run against a 4.2.0 library. Probably you have 4.2.0 installed on your system. Run "ldd exhello" to see which library exhello is picking up.

Craig Harrison

Ah, ok, I had two versions installed. I did one with yum and one manually.

I uninstalled the yum 4.2.0 one and now just have 4.2.1 installed.

Now when I go to run exhello (NOT as root ;)):

./exhello: error while loading shared libraries: liballeg.so.4.2: cannot open shared object file: No such file or directory

here is this:

[Craig@localhost ~]$ ls /usr/lib/liballeg*
ls: /usr/lib/liballeg*: No such file or directory

[Craig@localhost ~]$ ls /usr/local/lib/liballeg*
/usr/local/lib/liballeg-4.2.1.so  /usr/local/lib/liballeg_unsharable.a
/usr/local/lib/liballeg.so.4.2

it looks to me like the file is there... is it looking in the wrong place?

kazzmir

In your .bashrc add a line like this

$ vi ~/.bashrc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

Replace vi with your favorite editor, like nano or pico. Someone is going to come along and say you can edit /etc/ld.so.conf but I think this is less noob friendly.

After adding that line to your bashrc restart the terminal program and run exhello.

What this does is add /usr/local/lib to the list of directories linux looks in when it goes to run a program. Since allegro is a shared library it is loaded at runtime. LD_LIBRARY_PATH is one way to tell the run-time system where things are located.

Craig Harrison

It works! Thanks a bunch!

Is there any way to do it so that other people I give the programs to don't have to do this? Something like in Windows giving them the dll with the program?

Milan Mimica

Yes. Compile statically.

Craig Harrison

Ok, well, I must be doing something wrong here.

This works fine:
g++ -o tri_linux main.cpp `allegro-config --libs`

But when I try to staticlly link them:
g++ -o tri_linux main.cpp `allegro-config --static`

it says:
/usr/bin/ld: cannot find -lalleg
collect2: ld returned 1 exit status

I tried finding -lalleg and pasting it into /usr/bin/ld, but I couldn't find it anywhere. I'm sure it's something simple, but I'm not sure what to do.

Thomas Fjellstrom

Yeah, you'll have to rebuild allegro with the static libs enabled. By default only the dynamic lib is built.

Craig Harrison

call make uninstall or make clean or something first, or can I just install static libaries and leave the dynamic ones from before?

Then su -c 'make install <something?>'

Could someone spell it out for me, please? :)

Thomas Fjellstrom

The unix build docs spell it out for you :)

Craig Harrison

Ok got it. Thanks! That should be the last of my questions (for a little while).

Thread #588905. Printed from Allegro.cc