When compiling PHP with LDAP support on Debian-based systems, developers often encounter the frustrating error:
configure: error: Cannot find ldap libraries in /usr/include
This occurs despite having installed the development headers via:
sudo apt-get install libldb-dev
The key misunderstanding lies in the --with-ldap
parameter. While it might seem logical to point to header files:
./configure --with-ldap=/usr/include
This actually expects the LDAP library path, not header files. The development packages typically install headers in /usr/include
while libraries go to /usr/lib
.
# Install both development packages
sudo apt-get install libldap2-dev libsasl2-dev
# Correct configure command
./configure --with-ldap=/usr/lib \
--with-ldap-sasl=/usr
Before running configure, verify both headers and libraries are present:
# Check headers
ls -la /usr/include/ldap*.h
# Check libraries
ls -la /usr/lib/x86_64-linux-gnu/libldap*
For custom installations or multiple PHP versions:
./configure \
--with-ldap=shared,/usr \
--with-ldap-sasl=/usr \
LDFLAGS="-L/usr/lib/x86_64-linux-gnu" \
CPPFLAGS="-I/usr/include -I/usr/include/sasl"
- Using 32-bit libraries on 64-bit systems (or vice versa)
- Forgetting SASL dependencies when LDAP authentication is needed
- Specifying incorrect paths in multi-arch systems
To get more detailed error information during configuration:
make clean
./configure --with-ldap=/usr --enable-debug
Check config.log for specific linker errors that might reveal missing dependencies.
When compiling PHP with LDAP support on Debian-based systems, developers often encounter the frustrating error:
configure: error: Cannot find ldap libraries in /usr/include
This occurs even after installing development headers via:
sudo apt-get install libldb-dev
The problem stems from a disconnect between header files and actual library binaries. While libldb-dev
provides necessary headers like:
ldap.h
ldap_features.h
ldap_schema.h
It doesn't automatically solve the library dependency chain. The configure script needs both headers and the shared object libraries.
Here's what actually works for a proper PHP LDAP compilation:
sudo apt-get install libldap2-dev
sudo apt-get install libsasl2-dev
./configure --with-ldap=shared,/usr
Key differences from the original approach:
libldap2-dev
provides both headers and library binaries- The
--with-ldap
parameter points to/usr
instead of/usr/include
shared
flag enables dynamic linking
After successful compilation, verify LDAP support:
php -i | grep LDAP
Should return:
LDAP Support => enabled
1. 32-bit vs 64-bit mismatch:
# For 64-bit systems needing 32-bit compatibility:
sudo apt-get install libc6-dev-i386
2. Custom OpenLDAP installations:
# When using custom built OpenLDAP
./configure --with-ldap=/usr/local/openldap
3. SASL authentication requirements:
# If needing SASL support
sudo apt-get install libsasl2-modules-gssapi-mit
Check actual library locations:
ldconfig -p | grep libldap
Sample output should show:
libldap-2.4.so.2 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libldap-2.4.so.2