The more I think about it, the more fundamental the problem appears to be. If a library uses LDAP, i.e. libldap{,_r}, it can't know whether it will be used in a threaded or non-threaded world. Should it link to libldap or to libldap_r?