bearded / ruby-ldap

Ruby/LDAP is an extension library for Ruby. It provides the interface to some LDAP libraries (e.g. OpenLDAP, Netscape SDK and Active Directory). The common API for application development is described in RFC1823 and is supported by Ruby/LDAP.
http://rubyforge.org/projects/ruby-ldap/
Other
66 stars 35 forks source link

Reason for linking against both libldap and libldap_r #13

Open jeremyevans opened 12 years ago

jeremyevans commented 12 years ago

In the extconf.rb file, for OpenLDAP2, ruby-ldap attempts to link to both libldap and libldap_r: https://github.com/alexey-chebotar/ruby-ldap/blob/master/extconf.rb#L189

This causes problems on OpenBSD, since both ldap and ldap_r may define the same symbols, but they may be defined differently. This causes the following warning message when ruby-ldap is loaded:

ruby18:/usr/local/lib/libldap_r.so.12.0: /usr/local/lib/libldap.so.12.0 : WARNING: symbol(ldap_int_global_options) size mismatch, relink your program

Installing the gem using either --without-libldap or --without-libldap_r fixes the problem. Is there a reason ruby-ldap attempts to load both ldap and ldap_r? If not, is there a preference for loading ldap or ldap_r? I maintain the ruby-ldap port for OpenBSD, and am leaning towards using --without-libldap_r, but would like to make sure that will not cause other problems.

bearded commented 10 years ago

@jeremyevans, please excuse me that response took so long, but I do not know the reason, and I still do not have good knowledge of C, but I keep hope to dig into this question as soon as possible.

fmbiete commented 10 years ago

ldap_r is the thread-safe version of the library. Both of them declare the same symbols, so you only need to link against one. IMO linking against ldap_r only would be the best option:

Applications with multiple threads calling OpenLDAP need to use libldap_r,
even if they don't share LDAP connections; otherwise, resolver and certain
other calls made for independent LDAP connections will not be thread-safe
and may clobber global data owned by the system library.

http://mail-archives.apache.org/mod_mbox/apr-dev/200904.mbox/%3Ccc67648e0904071045n75185279w2f3fdc72f556795d@mail.gmail.com%3E

An example would be a rails application using Puma or Passenger Enterprise