Fix linking of OpenLDAP libraries - Mailing list pgsql-hackers

From Albe Laurenz
Subject Fix linking of OpenLDAP libraries
Date
Msg-id 52EF20B2E3209443BC37736D00C3C13809FB5BB7@EXADV1.host.magwien.gv.at
Whole thread Raw
Responses Re: Fix linking of OpenLDAP libraries
List pgsql-hackers
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

pgsql-hackers by date:

Previous
From: Douglas McNaught
Date:
Subject: Re: PostgreSQL on 64 bit Linux
Next
From: "Joshua D. Drake"
Date:
Subject: Re: Replication