PHP configure not finding LDAP header libraries

35,395

Solution 1

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

Solution 2

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 ];
then
    ln -s "$(locate liblber-2.4.so.2)"
fi

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

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

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

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

Configure PHP:

./configure --with-ldap=/usr

Solution 3

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.

Solution 4

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

Solution 5

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.

Share:
35,395

Related videos on Youtube

Shawn Welch
Author by

Shawn Welch

https://www.linkedin.com/in/prolampdev/

Updated on September 18, 2022

Comments

  • Shawn Welch
    Shawn Welch over 1 year

    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.
    
    • Goladus
      Goladus over 4 years
      How is a question about compiling PHP off-topic for server fault? Are no less than FIVE moderators truly unaware that PHP is a ubiquitous "information technology system used in business environments" and that IT professionals are commonly tasked with managing it? Do they not realize that compiling server software is a bread-and-butter System Administration task? There is no valid reason to close this question and it being "off topic" is just flat-out absurd.
    • Shawn Welch
      Shawn Welch over 4 years
      @Goladus Thank you! Yes. Not sure how this is NOT server related.
  • Shawn Welch
    Shawn Welch over 9 years
    Tried it. Doesn't work. configure: error: Cannot find ldap libraries in /usr/lib.
  • yrk
    yrk over 9 years
    Updated the answer. Please follow-up.
  • Wtower
    Wtower about 8 years
    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.
  • prog_24
    prog_24 about 8 years
    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
  • Iago Leão
    Iago Leão over 5 years
    For me --with-ldap=yes found.
  • Richard
    Richard about 4 years
    Dockerfile....... RUN apt-get update && apt-get install -y \ libldap2-dev \ libldb-dev \ && 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
  • Spencer Williams
    Spencer Williams over 3 years
    Jesus H. Christ...