My project tree looks something like that:
src/ include/ Makefile lib/ lib/3rdparylib/
I didn't code
3rdpartylib, but decided to embed its source code in my project packaging. I compile the software by doing the following steps:
$ cd lib/3rdpartylib/ $ make $ ln -s 3rdpartylib.so.0 3rdpartylib.so
Then I compile each of my source files like this:
$ gcc -c src/file.c -I include -o file.o -l 3rdparylib -L lib/3rdpartylib -I lib/3rdpartylib/include
Then I link:
$ gcc file1.o file2.o -l3rdpartylib -L lib/3rdpartylib -o myapp
When I am on my main machine, it works perfectly. Today I tried to launch it on another machine. It compiled and linked without any problem. However when I tried to launch the application I got the following error message.
./myapp: error while loading shared libraries: 3rdpartylib.so.0: cannot open shared object file: No such file or directory
I tried doing the following:
It seems to work. But I understand that using LD_LIBRARY_PATH is a bad practice. It bothers me to have this variable set up every time I want to run my app.
What am I missing? Why does it work on my main machine (where LD_LIBRARY_PATH is not set to anything) and not on the other machine? Does it matter that the other machine is a virtual one?
If it is of any help, my main machine is a Debian box, and my "new" machine is a Sabayon (Gentoo), running in Virtualbox.