I ran into an unexpected problem: I need a Linux task which handles Postgres (over libpq) Db queries and Oracle (over libclntst.so) Db queries. Creating a program to do one without the other is straightforward/routine.
However, a program that links in libpq and its dependent libraries plus Oracle's shared client library cores in OCIServerAttach.
Now if I try to make the same program by linking in only archive versions of libpq, libpq's dependent libs like ssh/ldap/crypto --and-- libclntst.a there's a zillion duplicated symbols mostly of the ssh/ldap/crypto variety. I'm guessing the shared library approach hides those conflicts and incorrectly resolves them at runtime.
I am versant with OCI, and libpq calls. All this code is doing is connecting resp. to a PG db and an Oracle Db ... 100% sure it's not the code itself but rather linking issues. Indeed, if I remove the PG PQconnect/PQfinish call and libpq from the linker line ... Oracle works as expected. And vice-versa.
We're migrating an extremely large Oracle Db to Postgres and would prefer to do it by use-case ... therefore our main task sometimes needs to hit PG and sometimes needs to hit Oracle.
Any ideas? I considered ODBC for Oracle ... but ultimately ODBC is just another library which still requires libclntst.a which will hit into the same issue. Is there a modular way to link Oracle to get Oracle APIs without ssl/ldap/crypto? Another author recommended using dlopen to hand-load the Oracle shared library with a special flag. I tried that ... but didn't get too far. I don't believe dlsym is a recursive loader anyway ... and we're talking serious numbers of function calls for Oracle.