LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Difference in output of ldd command with and without sudo (https://www.linuxquestions.org/questions/linux-newbie-8/difference-in-output-of-ldd-command-with-and-without-sudo-4175563039/)

MahendraL 01-04-2016 03:36 AM

Difference in output of ldd command with and without sudo
 
Hi,
I'm working on following Linux OS.
Ubuntu 14.04.3 LTS \n \l
Linux Debian jessie/sid ( 3.13.0-62-generic x86_64)

I'm seeing difference in output of ldd command with and without sudo for the same executable as below.

$ ldd ./hpcc
linux-vdso.so.1 => (0x00007fff74ba6000)
libmpi.so.12 => /home/lml/install_1/lib/libmpi.so.12 (0x00007f4a5559a000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f4a5537c000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f4a55076000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4a54cb1000)
libOpenCL.so.1 => /usr/lib/x86_64-linux-gnu/libOpenCL.so.1 (0x00007f4a54aa8000)
libibmad.so.5 => /usr/lib/x86_64-linux-gnu/libibmad.so.5 (0x00007f4a5488f000)
libibumad.so.3 => /usr/lib/x86_64-linux-gnu/libibumad.so.3 (0x00007f4a54688000)
libibverbs.so.1 => /usr/lib/libibverbs.so.1 (0x00007f4a5447b000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f4a54273000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f4a5405d000)
/lib64/ld-linux-x86-64.so.2 (0x00007f4a55c31000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f4a53e59000)

$ sudo ldd ./hpcc
[sudo] password for lml:
linux-vdso.so.1 => (0x00007fffc1d61000)
libmpi.so.12 => not found
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd9c81ad000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd9c7ea7000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd9c7ae2000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd9c83cb000)

Why is libmpi.so.12 not found when ldd is run with sudo command.
Because of this, when I run hpcc executable under sudo, I get following error.

$ sudo mpirun -np 4 ./hpcc
./hpcc: error while loading shared libraries: libmpi.so.12: cannot open shared object file: No such file or directory

Thank you.
LML

berndbausch 01-04-2016 04:44 AM

Root doesn't know about libraries located in /home/lml. The environment variable LD_LIBRARY_PATH contains the directories to search for libraries; check its value for lml and for root.

Note that for security reasons the user's environment is not inherited by default when running sudo. This behaviour can be changed in the sudoers file.


All times are GMT -5. The time now is 12:54 AM.