I am working with a lot of cross-platform software (Linux + Windows). Part of the software uses OCI, but up to now only on Windows. Now I complied for Linux, and after not much work, it is operating. But I am not sure whether I am on the right trail with linking to $ORACLE_HOME/lib/libclntsh.so.
My doubts:
• My database tool is 0.6 MB, libclntsh.so.12.1 is 57.4 MB. Oooops???
• I linked to $ORACLE_HOME/lib/libclntsh.so (that is a link to libclntsh.so.12.1). Now my program searches for libclntsh.so.12.1 at run-time. That isn't portable!
• If I link to the static library, the manuals say, I have to rebuild the static library with each version, and I have to re-link with each db version. So I get m x n versions of my software.
• After the standard installation, each and every user using the tool must have an environment set, at least ORACLE_HOME. If not, my tool seems to find the .so (maybe from /etc/ld.so.cache?), but the first call OCIEnvNlsCreate() fails, and since there is no handle for error description, it tells me that there is no chance to get the error description. With ORACLE_HOME, it works fine.
• The client installation didn't leave libclntsh.so in /lib, /lib64 or /usr/lib64 or any such directory. This seems to match the concept "You may install different clients at the same time."
• My $ORACLE_HOME/lib/libclntst12.a is of size zero. Why???
I have a plan I am about to try, but before I try the hard way, I would like to ask for your experience. Here is my plan:
• Check the environment for $ORACLE_HOME, and throw an error, if it isn't defined.
• Use using dlopen() to load $ORACLE_HOME/lib/libclntsh.so at run-time (instead of load-time!).
• Retrieve addresses of the functions by dlsym().
• Call OCI functions indirectly.
Is this plan OK?
Which other options are there, and which approach is the "commonly used"?
Would it be good to use the oldest/newest static library, can it be used with any ORACLE_HOME? Surely not...
I have tried to google information about it, but I only found an overwhelming lot of installation issues. Everybody is installing products which don't find the correct .so file — this is exactly what I am trying to avoid.
Thank you very much in advance for a short notice.