Why I cannot override search path of dynamic libraries with LD_LIBRARY_PATH?
From http://man7.org/linux/man-pages/man8/ld.so.8.html
When resolving shared object dependencies, the dynamic linker first
inspects each dependency string to see if it contains a slash (this
can occur if a shared object pathname containing slashes was
specified at link time). If a slash is found, then the dependency
string is interpreted as a (relative or absolute) pathname, and the
shared object is loaded using that pathname.If a shared object dependency does not contain a slash, then it is
searched for in the following order:o (ELF only) Using the directories specified in the DT_RPATH dynamic
section attribute of the binary if present and DT_RUNPATH
attribute does not exist. Use of DT_RPATH is deprecated.o Using the environment variable LD_LIBRARY_PATH. Except if the
executable is a set-user-ID/set-group-ID binary, in which case it
is ignored.o (ELF only) Using the directories specified in the DT_RUNPATH
dynamic section attribute of the binary if present.o From the cache file /etc/ld.so.cache, which contains a compiled
list of candidate shared objects previously found in the augmented
library path. If, however, the binary was linked with the -z
nodeflib linker option, shared objects in the default paths are
skipped. Shared objects installed in hardware capability
directories (see below) are preferred to other shared objects.o In the default path /lib, and then /usr/lib. (On some 64-bit
archiectures, the default paths for 64-bit shared objects are
/lib64, and then /usr/lib64.) If the binary was linked with the
-z nodeflib linker option, this step is skipped.
with readelf
readelf -d libfftw3_mpi.so
you can check if your lib contains such a attribute in the dynamic section.with
export LD_DEBUG=libs
you can debug the search path used to find your libswith
chrpath -r<new_path> <executable>
the rpath can be changed
modify ld library search path on cluster (no root access)
thank you very much for your suggestions. I found the issue and solved the problem. In essence, I needed these additional flags to configure:
sh ../gcc-6.5.0/configure --prefix=/home/xyz/ --build=x86_64-linux-gnu --enable-languages=c,c++,fortran --with-mpfr=/home/xyz/ --with-gmp=/home/xyz/ --with-mpc=/home/xyz/
These posts were helpful: 1, 2, 3
Thank you again for the time you have invested to help me.
LD_LIBRARY_PATH precendence and trouble with compiling
If anyone is still reading this, I engaged in some "personnel engineering" to solve the problem, i.e. got the system admins to re-install R so that it had everything I needed. Was certainly nice of them. Thanks very much to everyone who gave suggestions. Would like to keep going on some of them, but I've got to get busy on this project. Much obliged!
LD_LIBRARY_PATH vs LIBRARY_PATH
LIBRARY_PATH
is used by gcc before compilation to search directories containing static and shared libraries that need to be linked to your program.
LD_LIBRARY_PATH
is used by your program to search directories containing shared libraries after it has been successfully compiled and linked.
EDIT:
As pointed below, your libraries can be static or shared. If it is static then the code is copied over into your program and you don't need to search for the library after your program is compiled and linked. If your library is shared then it needs to be dynamically linked to your program and that's when LD_LIBRARY_PATH
comes into play.
Related Topics
How to Run Multiple Tor Processes at Once with Different Exit Ips
How to Set Up Curl to Permanently Use a Proxy
Redirecting Output of Bash for Loop
How to Define a Bash Alias as a Sequence of Multiple Commands
How to Map a Hostname *And* a Port with /Etc/Hosts
How to Tar Certain File Types in All Subdirectories
How to Find Files Recursively by File Type and Copy Them to a Directory
How to Convert an Image to Grayscale via the Command Line
How to Prepend a Directory the Library Path When Loading a Core File in Gdb on Linux
Systemd with Multiple Execstart
How to Diff Directories Over Ssh
Does the Thundering Herd Problem Exist on Linux Anymore
How to Statically-Link a Complex Program
Best Posix Way to Determine If a Filesystem Is Mounted Read Only
"Couldn't Find a File Descriptor Referring to the Console" on Ubuntu Bash on Windows