Thanks, Sdhamoth, because I found each version of Oracle client on Linux has different soname. for example oracle 11gr2 client is libclntsh.so.11.1, but oracle 18.3 name is libclntsh.so.18.3. so if my application is link to oracle 11GR2 client. on user side if they install 18.3 instant client, then my application will not be able work. since cannot find libclntsh.so.11.1. that why I try to static link to OCI library. If static link is not recommended, can you tell me how to handle this scenario?
Thank you very much:)
May be you can create symbolic links libclntsh.so, libclntshcore.so to libclntsh.so.X.Y, libclntshcore.so.X.Y respectively in the lib directory and link your application with libclntsh.so. Same can be followed in user side too.
create symbolic linke libclntsh.so to libclntsh.so.X.Y doesn't work. the library's soname is libclntsh.so.11.1 (11GR2), when I linked with 11GR2 client. the app still looking for libclntsh.so.11.1. in order to work properly, i have to create symbolic named libclntsh.so.11.1 to libclntsh.so.18.3 (if i installed oracle 18C instant client)
below output show libclntsh.so.11.1 is required. and I use follow command build a.out
g++ test.cpp -I /root/instantclient_11_2/sdk/include -lclntsh -L/root/instantclient_11_2
[root@localhost test]# readelf -a a.out | grep NEED
[ 8] .gnu.version_r VERNEED 0000000000400590 00000590
0x0000000000000001 (NEEDED) Shared library: [libclntsh.so.11.1]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000006ffffffe (VERNEED) 0x400590
0x000000006fffffff (VERNEEDNUM) 1
[root@localhost instantclient_11_2]# readelf -a libclntsh.so.11.1 | grep soname
0x000000000000000e (SONAME) Library soname: [libclntsh.so.11.1]
Looks like, creating the symbolic link libclntsh.so.11.1 for libclntsh.so.18.3 is the only solution for your scenario.
Sdhamoth-Oracle I saw this before, in my opinion this is not user friendly, because user have to create a special symbolic link manually if install oracle instant client. full client will create those link automatically.
On Windows platform app link to OCI, user can install any version of oracle client. that is why I ask if I could static link oci library.
Thanks for your feedback. I'll forward it to our management team.