How to Cross Compile OpenLDAP a Step by Step Guide
Introduction
This tutorial will show how to cross compile the OpenLDAP software on an GNU Linux embedded platform.
Overview of the project
OpenLDAP Software is an open source implementation of the Lightweight Directory Access Protocol. The suite includes:
- slapd - stand-alone LDAP daemon (server)
- slurpd - stand-alone LDAP update replication daemon
- libraries implementing the LDAP protocol, and
- utilities, tools, and sample clients.
Also available from the OpenLDAP Project:
- JLDAP - LDAP Class Libraries for Java contributed by Novell
- JDBC-LDAP - Java JDBC - LDAP Bridge Driver contributed by Octet String
To find out more about OpenLDAP and its components see the project's website http://www.openldap.org.
Download
OpenLDAP software releases can be found at: http://www.openldap.org/software/download/.
The latest available releases by the time of writing of this tutorial are 2.4.8 (February 19th 2008) and 2.3.41 (February 19th 2008). But the release considered by the project as the most reliable is 2.3.39 (November 18th 2007), this is the one we will cover on this tutorial.
To download this release, just type the following command:
wget ftp://ftp.openldap.org/pub/OpenLDAP/openldap-stable/openldap-stable-20071118.tgz
Environment Setup
The host machine will be a PC with a GNU Linux distribution installed.
The embedded platform might be constructed on top of one of the following architectures:
- arm.
- mips.
- mipsel.
- ppc.
- sparc.
Prerequisites
To cross compile the OpenLDAP software, you need either a cross compiler, or an emulated Linux running on top of a virtualization software such as QEMU, matching your specific targeted platform.
In order to build yourself such a cross compiler, at crosstool page we introduced the way to build a C,C++ 4.1 GNU compiler for an ARM platform.
Also, hackers will be interested finding all the details to setup an ARM Debian system on their traditional Ubuntun distro following the indications quoted in this other arm-debian-on-ubuntu.
Concerning the dependencies requested by OpenLDAP 2.3.39, we assume that the following software also installed:
- Berkeley Database 4.5.20 (OpenLDAP is not compliant with releases not between 4.2 and 4.5).
In order to cross compile this release of the Berkeley Database, you are invited to repeat the procedure described in this link Berkeley Database 4.6.21. The result of the compilation will have to be located in/opt/external/db/4.5.20/compiled/xxx-yyy-linux-gnu/
.
The Cross compilation process
Option 1: Using a cross compiler
Assumptions
During the process, we will assume the cross toolchain is called xxx-yyy-linux-gnu, meaning that the gcc, g++, ar, ..., ld utilities are prefixed by xxx-yyy-linux-gnu. For example, for this toolchain the C compiler is called xxx-yyy-linux-gnu-gcc.
We will also assume that the bin, include, lib and libexec folders of the cross toolchain are accessible through the PATH variable environment in order to work with the compilers from any place in the file system.
Finally, we suppose it is intalled in the following folder: /opt/crosstool/gcc-4.1.2-glibc-2.3.2/xxx-yyy-linux-gnu.
Organization
As mentioned above:
- The release being cross compiled is:
2.3.39
- The tar.gz file will then be extracted under:
/opt/external_packages/openldap/2.3.39/source
- The results of the compilation will be stored under:
/opt/external_packages/openldap/2.3.9/compiled/xxx-yyy-linux-gnu
The files resulting from the cross compilation are listed here (the content of the man folder is intentionaly not displayed):
.: total 32 drwxr-xr-x 2 root root 4096 2008-03-06 20:20 bin drwxr-xr-x 3 root root 4096 2008-03-06 20:12 etc drwxr-xr-x 2 root root 4096 2008-03-06 20:20 include drwxr-xr-x 2 root root 4096 2008-03-06 20:20 lib drwxr-xr-x 2 root root 4096 2008-03-06 20:20 libexec drwxr-xr-x 6 root root 4096 2008-03-06 20:21 man drwxr-xr-x 2 root root 4096 2008-03-06 20:20 sbin drwxr-xr-x 5 root root 4096 2008-03-06 20:20 var
./bin: total 1096 lrwxrwxrwx 1 root root 10 2008-03-06 20:20 ldapadd -> ldapmodify -rwxr-xr-x 1 root root 138732 2008-03-06 20:20 ldapcompare -rwxr-xr-x 1 root root 180232 2008-03-06 20:20 ldapdelete -rwxr-xr-x 1 root root 148792 2008-03-06 20:20 ldapmodify -rwxr-xr-x 1 root root 138948 2008-03-06 20:20 ldapmodrdn -rwxr-xr-x 1 root root 138776 2008-03-06 20:20 ldappasswd -rwxr-xr-x 1 root root 200320 2008-03-06 20:20 ldapsearch -rwxr-xr-x 1 root root 138732 2008-03-06 20:20 ldapwhoami
./etc: total 4 drwxr-xr-x 3 root root 4096 2008-03-06 20:20 openldap
./etc/openldap: total 24 -rw------- 1 root root 886 2008-03-06 20:20 DB_CONFIG.example -rw-r--r-- 1 root root 246 2008-03-06 20:12 ldap.conf -rw-r--r-- 1 root root 246 2008-03-06 20:20 ldap.conf.default drwxr-xr-x 2 root root 4096 2008-03-06 20:20 schema -rw------- 1 root root 2370 2008-03-06 20:20 slapd.conf -rw------- 1 root root 2370 2008-03-06 20:20 slapd.conf.default
./etc/openldap/schema: total 208 -r--r--r-- 1 root root 8231 2008-03-06 20:20 corba.schema -r--r--r-- 1 root root 20591 2008-03-06 20:20 core.ldif -r--r--r-- 1 root root 19762 2008-03-06 20:20 core.schema -r--r--r-- 1 root root 74080 2008-03-06 20:20 cosine.schema -r--r--r-- 1 root root 1553 2008-03-06 20:20 dyngroup.schema -r--r--r-- 1 root root 6360 2008-03-06 20:20 inetorgperson.schema -r--r--r-- 1 root root 13984 2008-03-06 20:20 java.schema -r--r--r-- 1 root root 2471 2008-03-06 20:20 misc.schema -r--r--r-- 1 root root 7723 2008-03-06 20:20 nis.schema -r--r--r-- 1 root root 3391 2008-03-06 20:20 openldap.ldif -r--r--r-- 1 root root 1601 2008-03-06 20:20 openldap.schema -r--r--r-- 1 root root 19689 2008-03-06 20:20 ppolicy.schema -r--r--r-- 1 root root 2968 2008-03-06 20:20 README
./include: total 152 -rw-r--r-- 1 root root 13734 2008-03-06 20:19 lber.h -rw-r--r-- 1 root root 1521 2008-03-06 20:19 lber_types.h -rw-r--r-- 1 root root 9673 2008-03-06 20:19 ldap_cdefs.h -rw-r--r-- 1 root root 1945 2008-03-06 20:20 ldap_features.h -rw-r--r-- 1 root root 53866 2008-03-06 20:19 ldap.h -rw-r--r-- 1 root root 9523 2008-03-06 20:19 ldap_schema.h -rw-r--r-- 1 root root 3539 2008-03-06 20:20 ldap_utf8.h -rw-r--r-- 1 root root 37582 2008-03-06 20:20 slapi-plugin.h
./lib: total 3652 lrwxrwxrwx 1 root root 21 2008-03-06 20:20 liblber-2.3.so.0 -> liblber-2.3.so.0.2.27 -rw-r--r-- 1 root root 136423 2008-03-06 20:20 liblber-2.3.so.0.2.27 -rw-r--r-- 1 root root 178980 2008-03-06 20:20 liblber.a -rw-r--r-- 1 root root 900 2008-03-06 20:20 liblber.la lrwxrwxrwx 1 root root 21 2008-03-06 20:20 liblber.so -> liblber-2.3.so.0.2.27 lrwxrwxrwx 1 root root 21 2008-03-06 20:20 libldap-2.3.so.0 -> libldap-2.3.so.0.2.27 -rw-r--r-- 1 root root 619395 2008-03-06 20:20 libldap-2.3.so.0.2.27 -rw-r--r-- 1 root root 975824 2008-03-06 20:20 libldap.a -rw-r--r-- 1 root root 972 2008-03-06 20:20 libldap.la lrwxrwxrwx 1 root root 23 2008-03-06 20:20 libldap_r-2.3.so.0 -> libldap_r-2.3.so.0.2.27 -rw-r--r-- 1 root root 687079 2008-03-06 20:20 libldap_r-2.3.so.0.2.27 -rw-r--r-- 1 root root 1091780 2008-03-06 20:20 libldap_r.a -rw-r--r-- 1 root root 986 2008-03-06 20:20 libldap_r.la lrwxrwxrwx 1 root root 23 2008-03-06 20:20 libldap_r.so -> libldap_r-2.3.so.0.2.27 lrwxrwxrwx 1 root root 21 2008-03-06 20:20 libldap.so -> libldap-2.3.so.0.2.27
./libexec: total 1408 -rwxr-xr-x 1 root root 1257952 2008-03-06 20:20 slapd -rwxr-xr-x 1 root root 172028 2008-03-06 20:20 slurpd
./sbin: total 0 lrwxrwxrwx 1 root root 16 2008-03-06 20:20 slapacl -> ../libexec/slapd lrwxrwxrwx 1 root root 16 2008-03-06 20:20 slapadd -> ../libexec/slapd lrwxrwxrwx 1 root root 16 2008-03-06 20:20 slapauth -> ../libexec/slapd lrwxrwxrwx 1 root root 16 2008-03-06 20:20 slapcat -> ../libexec/slapd lrwxrwxrwx 1 root root 16 2008-03-06 20:20 slapdn -> ../libexec/slapd lrwxrwxrwx 1 root root 16 2008-03-06 20:20 slapindex -> ../libexec/slapd lrwxrwxrwx 1 root root 16 2008-03-06 20:20 slappasswd -> ../libexec/slapd lrwxrwxrwx 1 root root 16 2008-03-06 20:20 slaptest -> ../libexec/slapd
./var: total 12 drwxr-xr-x 2 root root 4096 2008-03-06 20:20 openldap-data drwxr-xr-x 2 root root 4096 2008-03-06 20:20 openldap-slurp drwxr-xr-x 2 root root 4096 2008-03-06 20:20 run
./var/openldap-data: total 4 -rw------- 1 root root 886 2008-03-06 20:20 DB_CONFIG.example
./var/openldap-slurp: total 0
./var/run: total 0
Cross Compiling
Step 1
Install the OpenLDAP software by untaring it in /opt/external_packages/openldap/2.3.39/source
folder and then cd
to this directory.
Note:
All the directories and files listed below must be moved from the openldap-2.3.39
folder
to its parent folder (/opt/external_packages/openldap/2.3.39/source
).
Directories and files:
aclocal.m4 build clients configure.in COPYRIGHT include libraries Makefile.in servers ANNOUNCEMENT CHANGES configure contrib doc INSTALL LICENSE README tests
Step 2
We want to cross compile OpenLDAP with the following options:
Standalone LDAP Daemon options
- slapd enabled
- ACI disabled
- cleartext passwords enabled
- crypt passwords disabled
- LAN manager passwords disabled
- SASL password verification disabled
- dynamic module support disabled
- DN rewriting in back-ldap and rwm overlay enabled
- reverse lookups of client hostnames disabled
- SLAPI support disabled
- SLPv2 support disabled
- TCP wrapper support disabled
SLAPD Backend options
- Berkeley DB backend enabled
- dnssrv backend disabled
- Hierarchical DB backend enabled
- ldap backend disabled
- ldbm backend disabled
- metadirectory backend disabled
- monitor backend enabled
- null backend disabled
- passwd backend disabled
- perl backend disabled
- relay backend enabled
- shell backend disabled
- sql backend disabled
SLAPD Overlay options
- In-Directory Access Logging overlay disabled
- Audit logging overlay disabled
- Deny operation overlay disabled
- Dynamic Group overlay disabled
- Dynamic List overlay disabled
- Last Modification overlay disabled
- Password Policy overlay disabled
- Proxy Cache overlay disabled
- Referential Integrity overlay disabled
- Return Code testing overlay disabled
- Rewrite/Remap overlay disabled
- Syncrepl provider overlay enabled
- Translucent proxy overlay disabled
- Attribute Uniqueness overlay disabled
- Value Sorting overlay disabled
Replication Daemon options
- building slurpd enabled
Step 3
Configure the OpenLDAP software by typing:
env CPPFLAGS="-I/opt/external_packages/db/4.5.20/compiled/xxx-yyy-linux-gnu/include" LDFLAGS="-L/opt/external_packages/db/4.5.20/compiled/xxx-yyy-linux-gnu/lib" CC="xxx-yyy-linux-gnu-gcc" ./configure --host=xxx-yyy-linux-gnu --prefix=/opt/external_packages/openldap/2.3.39/compiled/xxx-yyy-linux-gnu --without-yielding_select
Step 4
To compile and install the reSIProcate project, type successively make
and make install
. But before typing the second command, I invite you to do the following change in the build/shtool script (line 980):
if [ ".$opt_s" = .yes ]; then if [ ".$opt_t" = .yes ]; then echo "strip $dsttmp" 1>&2 fi strip $dsttmp || shtool_exit $? fi
becomes
if [ ".$opt_s" = .yes ]; then if [ ".$opt_t" = .yes ]; then echo "xxx-yyy-linux-gnu-strip $dsttmp" 1>&2 fi xxx-yyy-linux-gnu-strip $dsttmp || shtool_exit $? fi
You should find the directories and files listed above under /opt/external_packages/openldap/2.3.39/compiled/xxx-yyy-linux-gnu/
.
Option 2: Using QEMU
This section is not yet available.
Download
- arm-openldap-2.3.39-tar.gz
You may consult this section if you want to download the OpenLDAP software already cross compiled for your target platform if it is available. You can also contribute to expand the crosscompile.org community by uploading your own results in the case a given platform is not already supported.
Supported platforms
arm-unknown-linux-gnu
Written by David Sayada.