Fix linking of OpenLDAP libraries

From: "Albe Laurenz" <all(at)adv(dot)magwien(dot)gv(dot)at>
To: <pgsql-patches(at)postgresql(dot)org>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Fix linking of OpenLDAP libraries
Date: 2006-08-21 13:57:43
Message-ID: 52EF20B2E3209443BC37736D00C3C13809FB5BB7@EXADV1.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

I have realized that my modifications in configure.in and
src/interfaces/libpq/Makefile to link libpq against
OpenLDAP are buggy.

Here is a proposed patch to fix it.

I write this to pgsql-hackers too because I want to share
the difficulty I'm facing - maybe somebody has a better
idea.

To handle thread safety, OpenLDAP comes with a second
library libldap_r. The thread safe API is identical to
the normal API, the difference is that you must link
against libldap_r instead of libldap to get thead safety.

These are my problems:
- While libpq should be thread safe when ./configured with
--enable_thread_safety, the backend should be linked
against the normal libldap.
- At least on RedHat Linux, you need to link against the
pthread library too if you want to link against libldap_r,
because the latter has unresolved dependencies.

My solution:
- If thread safety is not desired, I link against libldap.
No problem.
- If thread safety is desired, I first try to link against
libldap_r without the thread libraries, and only if that
fails add the thread libraries to LIBS.
- I tweak src/backend/Makefile so that it strips libldap_r
and the thread libs from LIBS and replace it with
libldap if necessary.

That means that if --enable_thread_safety and --with-ldap
is both specified, all executables except 'postgres' will
be linked against libldap_r (and the thread libs, if
necessary).

I tested my patch on RedHat Enterprise Linux 3 and AIX 5.3.

The behaviour for Windows (use the native WLDAP32.DLL)
is unchanged.

Yours,
Laurenz Albe

Attachment Content-Type Size
ldaplink.patch application/octet-stream 4.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2006-08-21 13:59:34 Unable to post to -patches (was: Visual C++ build files)
Previous Message Martijn van Oosterhout 2006-08-21 13:57:21 Re: snapshot replication with pg_dump

Browse pgsql-patches by date

  From Date Subject
Next Message Magnus Hagander 2006-08-21 13:59:34 Unable to post to -patches (was: Visual C++ build files)
Previous Message Alvaro Herrera 2006-08-21 06:07:41 Updatable views