I installed the LDAP development headers:

apt-get install libldb-dev

This added a few ldap headers:

root@crunchbang:/usr/include# ls -la ldap*
-rw-r--r-- 1 root root  9466 Apr 23  2013 ldap_cdefs.h
-rw-r--r-- 1 root root  1814 Apr 23  2013 ldap_features.h
-rw-r--r-- 1 root root 65213 Apr 23  2013 ldap.h
-rw-r--r-- 1 root root  9450 Apr 23  2013 ldap_schema.h
-rw-r--r-- 1 root root  3468 Apr 23  2013 ldap_utf8.h

When I configure and reference the directory:

./configure --with-ldap=/usr/include

I get this error:

checking for LDAP support... yes
checking for LDAP Cyrus SASL support... no
checking size of long int... 4
configure: error: Cannot find ldap libraries in /usr/include.

closed as off-topic by Gerald Schneider, mdpc, kasperd, Jenny D, Rob Moir Jan 8 '18 at 19:33

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on Server Fault must be about managing information technology systems in a business environment. Home and end-user computing questions may be asked on Super User, and questions about development, testing and development tools may be asked on Stack Overflow." – Gerald Schneider, mdpc, Jenny D
If this question can be reworded to fit the rules in the help center, please edit the question.


I ran into this issue trying to get PHP extensions involved in a Docker container. Here is what I had to do:

  1. apt-get install libldb-dev libldap2-dev
  2. ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so \ && ln -s /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so

This worked for me perfectly.

Install LDAP libraries:

apt-get install libldb-dev

Create SO linker files:

updatedb --prunepaths=/mnt
cd /usr/lib

if [ ! -L liblber-2.4.so.2 ];
    ln -s "$(locate liblber-2.4.so.2)"

if [ ! -L liblber-2.4.so.2.8.3 ];
    ln -s "$(locate liblber-2.4.so.2.8.3)"

if [ ! -L liblber.so ];
    ln -s "$(locate liblber.so)"

if [ ! -L libldap.so ];
    ln -s "$(locate libldap.so)"

if [ ! -L libldap_r.so ];
    ln -s "$(locate libldap_r.so)"

Configure PHP:

./configure --with-ldap=/usr

  • Thanks for the answer. For Ubuntu Trusty, after installing libldb-dev, the following is sufficient: sudo ln -s /usr/lib/i386-linux-gnu/liblber.so /usr/lib, sudo ln -s /usr/lib/i386-linux-gnu/libldap.so /usr/lib. – Wtower Mar 21 '16 at 11:09
  • Also, make sure you are not specifying lib64 libraries path as that is a sure-fire way of making sure compilation fails. This is the actual fix! --with-libdir=lib64 \ //This is what I am referring to – prog_24 Mar 31 '16 at 12:54

The cleanest way to do it, according to this comment in the issues of the official PHP Docker image, is using libldap2-dev (in Debian/Ubuntu) and calling configure with --with-libdir=lib/x86_64-linux-gnu.


PHP Version 5.6.20 debian and based: su aptitude install libldb-dev ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so then, try to compile it


I had this same issue and none of the answers above helped. Then after some digging into PHP's configure file I found a different solution.

1) Check which lib directoriy you are using. If you use the switch --with-libdir=lib64 then you should have the libldap.so and the other .so files in /usr/lib64. If you are not specifying a libdir then the .so files should be in /usr/lib. You can create symlinks if the .so file are in a non-standard directory (like /usr/lib64) but you dont want to specify the libdir.

2) Use the switch --with-ldap=yes

I wonder why this is not documented in the configure help.

  • For me --with-ldap=yes found. – Iago Leão Nov 27 '18 at 0:24

(Assuming you're on Ubuntu) Please try configure --with-ldap-libs=/usr/lib/i386-linux-gnu/. If doesn't help, please extend your answer with details on which Linux distro do you use and which project you're building.

  • Tried it. Doesn't work. configure: error: Cannot find ldap libraries in /usr/lib. – Shawn Welch Oct 3 '14 at 17:58
  • Updated the answer. Please follow-up. – yrk Oct 3 '14 at 18:02
  • I don't think --with-ldap-libs is an option. I've tried --with-ldap-dir and it seemed to work but when I tried to use a php ldap function it didn't work. – Shawn Welch Oct 3 '14 at 19:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.