Search code examples
linkerdynamic-linkinghanadynamic-libraryldd

Why a program can run with a dynamic library not found?


After installing SAP HANA successfully, I can see the sapstartsrv process run:

# ps -ef | grep sapstartsrv
xn1adm     2143      1  0 Mar29 ?        00:00:05 /usr/sap/XN1/HDB00/exe/sapstartsrv pf=/home/hana/shared/XN1/profile/XN1_HDB00_dhe2 -D -u xn1adm

But after using ldd command to check sapstartsrv dynamic linking libraries:

# ldd /usr/sap/XN1/HDB00/exe/sapstartsrv
    linux-vdso.so.1 (0x00007ffd35a30000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007fd1fe6b3000)
    librt.so.1 => /lib64/librt.so.1 (0x00007fd1fe4ab000)
    libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007fd1fe270000)
    libpam.so.0 => /lib64/libpam.so.0 (0x00007fd1fe061000)
    libutil.so.1 => /lib64/libutil.so.1 (0x00007fd1fde5e000)
    libuuid.so.1 => /usr/lib64/libuuid.so.1 (0x00007fd1fdc59000)
    libsapnwrfccm.so => not found
    libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fd1fd8d7000)
    libm.so.6 => /lib64/libm.so.6 (0x00007fd1fd5d6000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fd1fd3bf000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fd1fd1a2000)
    libc.so.6 => /lib64/libc.so.6 (0x00007fd1fcdfb000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fd1fe8b7000)
    libaudit.so.1 => /usr/lib64/libaudit.so.1 (0x00007fd1fcbd8000)

I can see the libsapnwrfccm.so is not found. But why sapstartsrv program can run with a dynamic library not found?


Solution

  • Because something starts that program by pointing the linker to the directory containing that library. Usually this is done my setting the environment variable LD_LIBRARY_PATH. For example:

    LD_LIBRARY_PATH=/look/here/for/libs program
    

    The runtime linker will now also look in /look/here/for/libs to find libraries program depends on.