Reputation: 19482
I have a simple question.
Is there any standard folder accessible to non-root users to copy libraries into it?
When I try copying the library in /usr/lib/
It gives permission denied
.
sudo
is solving that problem. However I would like to know can if there is a way to do this without sudo
.
Goal is to be able to use the library without modifying any env variables.
Upvotes: 0
Views: 264
Reputation: 19641
Not unless the system administrator provides a directory which you can write to and updates the link loader configuration (/etc/ld.so.conf
and /etc/ld.so.conf.d/*
) to use it. Unlikely to happen, since that is considered a security risk.
However, if you want to avoid having to define the LD_LIBRARY_PATH
variable, you can install your libraries anywhere you have write access to and add the path to it in the executable files that use it (RPATH list in an ELF executable file).
For instance, if you are linking files using gcc
, you specify the RPATH with the -R
option:
gcc -o<output executable> -R<path to your libraries> -l<your shared library>
You can then run the resulting executable without defining LD_LIBRARY_PATH=<path to your libraries>
.
You can get the ELF RPATH list from an executable using:
readelf -a <executable file> | grep RPATH
For instance:
# readelf -a ar | grep RPATH
0x0000000f (RPATH) Library rpath: [/opt/local/i386-sun-solaris2.10/lib]
meaning this version of ar
will look for shared libraries in /opt/local/i386-sun-solaris2.10/lib
in addition to the standard system library directories.
Upvotes: 2