|OpenLDAP Faq-O-Matic : OpenLDAP Developer's FAQ : Porting OpenLDAP : Porting to MinGW : Building MinGW OpenLDAP in a Cygwin Environment|
Title: Building MinGW OpenLDAP in a Cygwin Environment|
Author: Jon Leichter, firstname.lastname@example.org
Last Modified: $Date: 2002/01/06 05:25:07 $
This document describes the steps to build MinGW OpenLDAP in a Cygwin Environment.
NOTE: At the time of this writing, MinGW support has been added to OpenLDAP's HEAD branch only. This support is limited to building and installing. There is no guarantee that MinGW OpenLDAP is stable.
The following is a road map to building MinGW OpenLDAP:
Install and configure the Cygwin Environment
There is so much to say about this topic that a separate document exists. It is mandatory that you read and follow the directions in the the MinGW Support in Cygwin document. All other steps laid out in this document assume that a proper Cygwin Environment has been installed and configured.
All packages need to be installed into its own MinGW-specific hierarchy. All steps in this document uses /usr/local/mingw.
Build and install GNU Regex
GNU Regex must be built and installed before building MinGW OpenLDAP. At the time of this writing, the latest version of GNU Regex was 0.12. Download regex-0.12.tar.gz into a temporary directory, e.g. /tmp. The tarball is available from GNU's FTP Server.
It is not necessary to build all of GNU Regex. Only its header file and object code is needed. GNU Regex's Makefile does not build a library nor does it install. It will be necessary to do these things manually:
$ cd /usr/src $ tar xfz /tmp/regex-0.12.tar.gz $ cd regex-0.12 $ env CC=mgcc ./configure --prefix=/usr/local/mingw i686-pc-mingw32 $ make subdirs= $ ar ru libregex.a regex.o $ mkdir -p /usr/local/mingw/include $ mkdir -p /usr/local/mingw/lib $ cp regex.h /usr/local/mingw/include $ cp libregex.a /usr/local/mingw/lib
Patch, build, and install GDBM
GDBM must be patched, built, and installed before building MinGW OpenLDAP. At the time of this writing, the latest vesion was 1.8.0. Download gdbm-1.8.0.tar.gz into a temporary directory, e.g. /tmp. The tarball is available from GNU's FTP Server.
GDBM must be patched because it does not support MinGW in its current state. The patches are fairly simple and can be found here. These patches have not been extensively tested, nor are they guaranteed to be correct. Save the text of the patches link into a file, e.g. /tmp/patches-gdbm.txt. You will be able to use this file to patch your distribution.
GDBM's Makefile complicates installation, so it's better to do it manually:
$ cd /usr/src $ tar xfz /tmp/gdbm-1.8.0.tar.gz $ cd gdbm-1.8.0 $ patch -i /tmp/patches-gdbm.txt $ env CC=mgcc ./configure --prefix=/usr/local/mingw --host=i686-pc-mingw32 $ make $ cp gdbm.h /usr/local/mingw/include $ ./libtool --mode=install cp libgdbm.la /usr/local/mingw/lib
Build, install, and patch GNU Libtool
GNU Libtool must be built, installed, and patched before building MinGW OpenLDAP. At the time of this writing, the latest version was 1.4.2. Download libtool-1.4.2.tar.gz into a temporary directory, e.g. /tmp. The tarball is available from GNU's FTP Server.
NOTE: The libtool components that are part of OpenLDAP's source distribution do NOT work with MinGW!
GNU Libtool attempts to generate a shell script and a dynamic library suitable for the build environment. The shell script MUST be used to build OpenLDAP. The library is needed for OpenLDAP if and only if you configure OpenLDAP with module support.
Building GNU Libtool for MinGW support in a Cygwin Environment is a bit tricky. GNU Libtool needs to be directed to generate "mingw" binaries. However, GNU Libtool sometimes uses the compiler for its own internal purposes. When it does this, it must generate "cygwin" binaries, otherwise pathnames in the Cygwin Environment will not get resolved correctly. GNU Libtool accounts for the possibility of the target compiler being different from the internal compiler. The HOST_CC environment variable is used to control this.
The libtool shell script that GNU Libtool generates for the current environment, i.e. MinGW in Cygwin, is not entirely correct. It requires patches. After GNU Libtool installs, you must update the /usr/local/mingw/bin/libtool script with the following patches. Save these patches to a temporary file, e.g. /tmp/patches-libtool.txt.
$ cd /usr/src $ tar xfz /tmp/libtool-1.4.2.tar.gz $ cd libtool-1.4.2 $ env CC=mgcc ./configure --prefix=/usr/local/mingw --host=i686-pc-mingw32 $ env HOST_CC=gcc make $ env HOST_CC=gcc make install $ cd /usr/local/mingw/bin $ patch -i /tmp/patches-libtool.txt
Build and install OpenLDAP
With all other prerequisite software components in place, MinGW OpenLDAP can now be built. First, you must fetch the source distribution. You can either use CVS or download a tarball. The following steps will assume that the source lives in /usr/src/ldap
NOTE: MinGW support was initally added to the HEAD branch. You will only find MinGW support in the tarball you are working with if the MinGW support was specifically migrated into that branch.
There are many options to choose from when building OpenLDAP. These options are controlled by switches specified to the configure script. For MinGW, many of these switches will work. Some will not. If you specify an unsupported switch, you'll find out soon enough during the configuration or build. An unsupported switch merely means that a component of OpenLDAP was not adapted for MinGW. That does not mean that it cannot be adapted. It just means that you will have to do the work yourself. Some of the options that MinGW does support are dynamic LDAP libraries (--enable-dynamic), dynamic backend module support (--enable-modules), the LDBM backend (default option), and the LDAP backend (--enable-ldap [--with-ldap-module=dynamic]).
All of the following commands are required to build plain OpenLDAP. Add configure switches as desired:
$ cd /usr/src/ldap $ env CC=mgcc CPPFLAGS=-I/usr/local/mingw/include \ LDFLAGS=-L/usr/local/mingw/lib \ ./configure --prefix=/usr/local/mingw --host=i686-pc-mingw32 $ env HOST_CC=gcc make depend LIBTOOL=/usr/local/mingw/bin/libtool $ env HOST_CC=gcc make LIBTOOL=/usr/local/mingw/bin/libtool $ env HOST_CC=gcc make install LIBTOOL=/usr/local/mingw/bin/libtoolCross your fingers, and enjoy!
email@example.com, Kurt@OpenLDAP.org, firstname.lastname@example.org
|[Append to This Answer]|
|Previous:||MinGW Support in Cygwin|