Linux binary can't find shared library, but works while running in strace
shared-libraries, strace
Solution
(Old question, but hopefully this will help somebody else)
Under new Linux installations, LD_LIBRARY_PATH is not used by the standard system runtime linker for programs with SUID set. It appears that strace, gdb and friends work differently, and do use LD_LIBRARY_PATH.
For suid programs, all libraries must be found in the system library cache. Check (as root) whether your "missing" library is present using
ldconfig -p | grep <my_library_name>
and, if anything's missing, add it to a new file in /etc/ld.so.conf or ld.so.conf.d/ as appropriate, and then rebuild using
ldconfig -v
Or remove the SUID bit if it's not required, of course.
Problem
(Note: names of the binary and binary and library below are obfuscated to protect the innocent. ;-) The app is proprietary under NDA but the behavior may not depend on it.) I have a Linux binary which prints the following error when run: binary: error while loading shared libraries: libshared.so: cannot open shared object file: No such file or directory Which is confusing on its own since libshared.so is in the LD_LIBRARY_PATH. However, The library is found correctly when running `ldd binary` (i.e., the ldd output points to the file location) The library is found correctly when running `strace binary`, so that the program manages to print its usage information! I have never seen an application which behaves differently when run on its own vs in strace, but I figure maybe someone else has seen this happen before? Any ideas how to resolve this? I don't have the source so I can't rebuild. Running the app in production under strace is probably a non-starter. The OS is RHEL 6.2.