Reputation: 405
I work on a Fedora Linux box.
I have a whole host of binaries and libraries that I've installed locally under my home directory.
I'd like to set my system up so installing software there functions the same way (for me) as if the root user installed it without a prefix.
I can run binaries installed in ~/local/bin just fine by adding that dir to my PATH variable, but what about linking to libraries in ~/local/lib and ~/local/lib64?
Is there something akin to LD_LIBRARY_PATH variable but to find the library at compile rather than runtime? I don't want to worry about explicitly passing the path to the compiler via L~/local/lib or through flags in the ./configure script.
Upvotes: 2
Views: 568
Reputation: 410552
Set the LIBRARY_PATH
environment variable to $HOME/local/lib:$HOME/local/lib64
. You can also set the environment variables C_INCLUDE_PATH
and CPLUS_INCLUDE_PATH
to find include files in $HOME/local/include
. These are environment variables used by GCC to find libraries and include files, so they probably won't work with other compilers.
Upvotes: 1
Reputation: 339786
There's two ways to get the libraries to work at runtime:
If the libraries are just for your use, and it's not a multi-user system, then use the $LD_LIBRARY_PATH
environment variable
If you're the only user on the system you could add your directories into /etc/ld.so.conf
, or into a new text file in /etc/ld.so.conf.d
. Run ldconfig
afterwards to rebuild the system's shared library cache
At compile time things aren't so clear. The GNU linker supports the -rpath
parameter and the $LD_RUN_PATH
environment variable to specify library paths. However in each case the result path ends up hard-coded in the binary, so if you subsequently want to move your files you'd have to recompile them.
I believe that programs built using ./configure
style scripts should be able to find any libraries that are in your $LD_RUN_PATH
, but haven't been able to test that.
In either event, running ./configure --prefix=${HOME}/local
should allow configure
to resolve both the include directories and the libraries.
Upvotes: 1
Reputation: 753475
As well as setting LD_LIBRARY_PATH, you can also look at /etc/ld.so.conf (which works for all users, even root). Also consider the security of your system if you use /etc/ld.so.conf; if people run the library from your directory, they are trusting you not to mess with them.
Upvotes: 0