Here are 3 situations of interest:
Your app is reading the libraries of /usr/lib64
, but you want it to read to libraries of $MAGICK_HOME/lib
:
If you are compiling you application, you could add some RPATH
or RUNPATH
rules so that the binary searches for libs in $ORIGIN/../lib64
. Otherwise, you could add $MAGICK_HOME/lib
to $LD_LIBRARY_PATH
in a shell script that starts your binary so the dynamic linker searches that path for binaries, or you could use ldconfig
to add a specific library to /etc/ld.so.cache
Your app is reading the libraries of $MAGICK_HOME/lib
instead of /usr/lib64
When ld.so dynamically links, it searches:
DT_RPATH
field compiled in the ELF-binary (if DT_RUNPATH
doesn't exist). This will usually be an absolute path, or a path relative to the location of the binary ($ORIGIN
). I don't think an environment variable like $MAGICK_HOME
can influence it.
$LD_LIBRARY_PATH
environment variable (unless being run in secure-execution mode)
DT_RUNPATH
field compiled in the ELF-binary (similar to DT_RPATH
above).
/etc/ld.so.cache
, which contains a compiled list of candidate shared objects.
- default paths of
/lib
and /usr/lib
. On some architetures, the default paths for 64-bit shared objects are /lib64
and /usr/lib64
. If the binary was linked with the -z nodeflib
linker option, this step is skipped.
Since /usr/lib64
is probably in the default path, I suspect the program is manipulating $LD_LIBRARY_PATH
when it starts, or used ldconfig
to add libraries into /etc/ld.so.cache
during installation. This would cause the $MAGICK_HOME/lib
libraries to be found first. If you can prevent it from doing these things, then it should fallback to /usr/lib64
.
You can use readelf
to see if it was compiled for a specific DT_RPATH
or DT_RUNPATH
, but I don't think that's the case because it sounds like an environment variable influences the linking and these options cannot (AFAIK) be influenced by the environment.
Your app is failing to start because it can't find the libraries installed in /usr/lib64
If the problem is not that it's loading the wrong binaries, but instead it's not loading any binaries, then it could be that /usr/lib64
is not in your default path. We'd need to know about your distro and architecture to help further in that case.