I am working on a project and recently I have changed static linking of oracle client library to dynamic loading of library whenever it actually try to call a function from OCI (Oracle client library/ libclntsh.so
), program will attempt dlopen()
with absolute path to libclntsh.so
. and it gives me following error
┌────────────────────────────────── Error ──────────────────────────────────┐
│ Could not open Dynamic Library: │
│ /aix64/oracle/client/12.1.0.2/client_1/lib/libclntsh.so (8013) │
│ DLL Error : Could not load module │
│ /aix64/oracle/client/12.1.0.2/client_1/lib/libclntsh.so. (8014) │
│ Unable to load shared library (14945) │
│ ORACLE error -1012 see "ORACLE Error Messages and Codes Manual". (1252) │
│ ** │
│ Failed to connect to ORACLE database lh. (1451) │
│ │
│ ────────────────────────────────────────────────────────────────────────── │
│ <OK> │
└────────────────────────────────────────────────────────────────────────────┘
PATH/LIBPATH
can't be the issue, as I am giving absolute path for libclntsh.so
in dlopen()
.
permission, owner and group of executable is:
-rwsrwxr-x 1 root frnd 25835393 Dec 13 19:18 /some/other/abc
While looking for the solution, I got to know that because of sticky bit set and file is owned by root, when I execute it, it is not able to get LIBPATH
.
Path to library is given, but two of its dependencies from same directory are not being loaded and hence this error.
Can anyone suggest something.
PS: When using 12.2.0.1.0 oracle library(ie: LIBPATH and ORACLE_HOME is pointing to /oracle/client/12.2.0.1.0/), there is no issue in loading. I don't understand how that happens.
TIA
You should examine libclntsh.so
to find out what dependencies it has: either ldd libclntsh.so
or dump -H -X64 libclntsh.so
will do.
It could be libons.so
or libclntshcore.so
depending on the version/variant.
Plus, the oracle client might open shared libraries with dlopen too (for InstantClient it is libociei.so
.
To sum up: you should set LIBPATH
to /aix64/oracle/client/12.1.0.2/client_1/lib
, then it might work.