qorelanguage / qore

Qore Programming Language
GNU General Public License v2.0
60 stars 10 forks source link

module-openldap: if the oracle module is loaded before the openldap module on Linux, the openldap module initialization fails #1043

Open davidnich opened 8 years ago

davidnich commented 8 years ago

ex:

dnichols@hq:~$ qore -loracle -lopenldap -X 'get_module_hash()'
cannot load 'openldap': failed to load module 'openldap':
 * -1: LOAD-MODULE-ERROR: module '/usr/lib64/qore-modules/openldap-api-0.19.qmod': feature 'openldap': initialization error: the openldap library returned error code -1: Operations error to the ldap_get_option(LDAP_OPT_API_INFO) function
please fix the errors listed above and try again.
dnichols@hq:~$ qore -lopenldap -loracle -X 'get_module_hash()'
hash: (2 members)
  openldap : hash: (12 members)
    filename : "/usr/lib64/qore-modules/openldap-api-0.19.qmod"
    name : "openldap"
    desc : "openldap module"
    version : "1.1"
    author : "David Nichols"
    url : "http://qore.org"
    license : "MIT"
    injected : False
    reinjected : False
    user : False
    api_major : 0
    api_minor : 20
  oracle : hash: (12 members)
    filename : "/usr/lib64/qore-modules/oracle-api-0.19.qmod"
    name : "oracle"
    desc : "Oracle database driver"
    version : "3.2"
    author : "David Nichols <david@qore.org>"
    url : "http://qore.org"
    license : "MIT"
    injected : False
    reinjected : False
    user : False
    api_major : 0
    api_minor : 20

tested on RHEL 5, CentOS 7, Fedora 23 - same results as above

davidnich commented 8 years ago

a workaround is to launch such processes like this: LD_PRELOAD="/appl/isepl/dev02/lib/libqore.so.5.13.0 /appl/isepl/dev02/lib/modules/openldap.qmod" cmd

pavelkveton commented 8 years ago

the same issue reproduced during https://bugs.qoretechnologies.com/issues/1406

pavelkveton commented 8 years ago

it seems that the solution is to link openldap library statically into module-openldap, otherwise we will always melt ldap.h from openldap with ldap_get_option implementation from (for example) oracle.

the question is whether we are able to link module-openldap with libldap statically and NOT export the ldap symbols...

pavelkveton commented 8 years ago

another problem is that not all linux distros provide static ldap libs (RHEL 7 has only shared ldap libs, for one)...

pavelkveton commented 8 years ago

it is not that easy to link ldap statically to module-openldap:

/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libldap_r.a(open.o): relocation R_X86_64_PC32 against symbol `ldap_int_global_options' can not be used when making a shared object; recompile with -fPIC