I have compiled casablanca
and have put -l:/~/path/to/lib/libcasablanca.so
in my CMakeList.txt
. I have build my application and I have got no errors. But when I run the executable it says:
./myproj: error while loading shared libraries: libcasablanca.so: cannot open shared object file: No such file or directory
I have done it on another computer and it seems to work fine.
Does anyone know what is the problem? How to fix this?
I have no administrator access to this machine.
In this standard, folders /lib, /usr/lib and /usr/local/lib are the default folders to store shared libraries. The /lib folder has libraries used during the boot time of the system but also used by programs in the /bin folder. Similarly, the/usr/lib folder has libraries used by programs in the /usr/bin folder.
According to the FHS, most libraries should be installed in /usr/lib, but libraries required for startup should be in /lib and libraries that are not part of the system should be in /usr/local/lib.
9.2. As shared libraries cannot be directly executed, they need to be linked into a system executable or callable shared object. Hence, shared libraries are searched for by the system linker during the link process. This means that a shared library name must always start with the prefix lib and have the extension .
This is very simple: your library is not in the default system path from them the shared libraries are imported. During the compilation, the compile scripts solved these problems. In runtime, you have the LD_PRELOAD
or LD_LIBRARY_PATH
environment variables.
For example: an export LD_LIBRARY_PATH=/home/darkside/wunderprog/lib
will extend the directoried searched for your libraries with the named directory. If there is your libcasablanca.so
, you will get what you want.
Normally I use a /home/<myusername>/lib
directory in my useronly accounts and set LD_LIBRARY_PATH
from .profile
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With