Unable to link to shared library under systemd

Does systemd do something funny with linking shared libraries?

I have a php extension which loads a shared library outside the php extension directory. If I run php-cli or start php-fpm from the CLI it works as expected and phpinfo() shows how the extension was built:

Compile-time ORACLE_HOME    /path/to/oracle_home
Libraries Used  -Wl,-rpath,/path/to/oracle_home/lib -L/path/to/oracle_home/lib -lclntsh

When starting php-fpm using systemd (systemctl), this error shows up in the logs:

NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/oci8.so' - libclntsh.so.12.1: cannot open shared object file: No such file or directory in Unknown on line 0

Shouldn’t the -lclntsh be using the rpath to find the needed library? Why does systemd break this?

Note: Adding the following to the unit file doesn’t help:

Environment=LD_LIBRARY_PATH=/path/to/oracle_home/lib

Nor does it help to add that path under /etc/ld.so.conf.d/

Answer

Attribution
Source : Link , Question Author : chell , Answer Author : Community

Leave a Comment