[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: FreeBSD link failures on lutil_getopt (ITS#2094)



A fix has been applied to OPENLDAP_REL_ENG_2 (available
via AnonCVS).  Please test.


At 09:34 AM 2002-09-20, B.Candler@pobox.com wrote:
>Full_Name: Brian Candler
>Version: 2.0.26
>OS: FreeBSD-4.6.2-RELEASE
>URL: ftp://ftp.openldap.org/incoming/brian-candler-020920.patch
>Submission from: (NULL) (212.139.129.125)
>
>
>Compilation of 2.0.26 under FreeBSD-4.6.2 and FreeBSD-4.4 fails as follows:
>
>cc -g -O2 -I../../include -I../../include     -c test.c
>/bin/sh /u/home/brian/build/openldap-2.0.26/libtool --mode=link cc  -g -O2
>-I../../include -I../../include    
>-L/u/home/brian/build/openldap-2.0.26/libraries   -o ltest test.o -lldap -llber
>-llutil   -lssl -lcrypto  -lssl -lcrypto  
>cc -g -O2 -I../../include -I../../include
>-L/u/home/brian/build/openldap-2.0.26/libraries -o ltest test.o -lldap -llber
>-llutil -lssl -lcrypto -lssl -lcrypto
>test.o: In function `main':
>/u/home/brian/build/openldap-2.0.26/libraries/libldap/test.c(.text+0x549):
>undefined reference to `lutil_optarg'
>/u/home/brian/build/openldap-2.0.26/libraries/libldap/test.c(.text+0x55e):
>undefined reference to `lutil_optarg'
>/u/home/brian/build/openldap-2.0.26/libraries/libldap/test.c(.text+0x565):
>undefined reference to `lutil_optarg'
>/u/home/brian/build/openldap-2.0.26/libraries/libldap/test.c(.text+0x575):
>undefined reference to `lutil_optarg'
>/u/home/brian/build/openldap-2.0.26/libraries/libldap/test.c(.text+0x591):
>undefined reference to `lutil_optarg'
>/u/home/brian/build/openldap-2.0.26/libraries/libldap/test.c(.text+0x5b6):
>undefined reference to `lutil_getopt'
>/u/home/brian/build/openldap-2.0.26/libraries/libldap/test.c(.text+0x5d0):
>undefined reference to `lutil_optind'
>/u/home/brian/build/openldap-2.0.26/libraries/libldap/test.c(.text+0x5e1):
>undefined reference to `lutil_optind'
>/u/home/brian/build/openldap-2.0.26/libraries/libldap/test.c(.text+0x5eb):
>undefined reference to `lutil_optind'
>*** Error code 1
>
>The problem appears to be autoconf related. On my system:
>
>include/portable.h:/* #undef HAVE_GETOPT_H */
>
>which means it will use getopt-compat.h. However in libraries/liblutil/Makefile
>getopt.o is not included in OBJS:
>
>SRCS    = base64.c debug.c entropy.c sasl.c signal.c \
>        md5.c passwd.c sha1.c getpass.c lockf.c utils.c sockpair.c \
>         getopt.c $(UNIX_SRCS)
>
>OBJS    = base64.o debug.o entropy.o sasl.o signal.o \
>        md5.o passwd.o sha1.o getpass.o lockf.o utils.o sockpair.o \
>         $(UNIX_OBJS)
>
>Hence liblutil doesn't include this object file, and thus the link failure.
>The following patch appears to fix it:
>
>--- openldap-2.0.26/configure.in.orig   Fri Sep 20 16:47:58 2002
>+++ openldap-2.0.26/configure.in        Fri Sep 20 16:48:11 2002
>@@ -2110,6 +2110,7 @@
> 
> if test "$ac_cv_func_getopt" != yes; then
>     LIBSRCS="$LIBSRCS getopt.c"
>+    LIBOBJS="$LIBOBJS getopt.o"
> fi
> 
> dnl ----------------------------------------------------------------
>
>However the build then fails at a later point:
>
>cc -g -O2 -I../../include -I../../include     -c slapd-tester.c
>/bin/sh /u/home/brian/build/openldap-2.0.26/libtool --mode=link cc  -g -O2
>-I../../include -I../../include    
>-L/u/home/brian/build/openldap-2.0.26/libraries   -o slapd-tester slapd-tester.o
>-lldap -llber   -lssl -lcrypto  -lcrypt  
>mkdir .libs
>cc -g -O2 -I../../include -I../../include
>-L/u/home/brian/build/openldap-2.0.26/libraries -o slapd-tester slapd-tester.o
>-lldap -llber -lssl -lcrypto -lcrypt
>slapd-tester.o: In function `main':
>/u/home/brian/build/openldap-2.0.26/tests/progs/slapd-tester.c(.text+0x139):
>undefined reference to `lutil_optarg'
>/u/home/brian/build/openldap-2.0.26/tests/progs/slapd-tester.c(.text+0x155):
>undefined reference to `lutil_optarg'
>/u/home/brian/build/openldap-2.0.26/tests/progs/slapd-tester.c(.text+0x171):
>undefined reference to `lutil_optarg'
>/u/home/brian/build/openldap-2.0.26/tests/progs/slapd-tester.c(.text+0x18d):
>undefined reference to `lutil_optarg'
>/u/home/brian/build/openldap-2.0.26/tests/progs/slapd-tester.c(.text+0x1a9):
>undefined reference to `lutil_optarg'
>slapd-tester.o(.text+0x1c1):/u/home/brian/build/openldap-2.0.26/tests/progs/slapd-tester.c:
>more undefined references to `lutil_optarg' follow
>slapd-tester.o: In function `main':
>/u/home/brian/build/openldap-2.0.26/tests/progs/slapd-tester.c(.text+0x233):
>undefined reference to `lutil_getopt'
>*** Error code 1
>
>This time because it forgot to link against -llutil. Second patch:
>
>--- openldap-2.0.26/tests/progs/Makefile.in.orig        Fri Jan  4 20:38:37
>2002
>+++ openldap-2.0.26/tests/progs/Makefile.in     Fri Sep 20 17:12:32 2002
>@@ -12,7 +12,7 @@
> LDAP_INCDIR= ../../include
> LDAP_LIBDIR= ../../libraries
> 
>-XLIBS    = -lldap -llber
>+XLIBS    = -lldap -llber -llutil
> XXLIBS = $(SECURITY_LIBS) $(LUTIL_LIBS)
> 
> # build-tools: FORCE
>
>and this time it does appear to compile and link properly.
>
>However, the other issue is that FreeBSD has getopt so why wasn't it
>detected and used?
>
>configure:4525: checking for getopt.h
>configure:4535: cc -E  conftest.c >/dev/null 2>conftest.out
>configure:4531: getopt.h: No such file or directory
>configure: failed program was:
>#line 4530 "configure"
>#include "confdefs.h"
>#include <getopt.h>
>
>Ah. The reason is that FreeBSD does not have a getopt.h header, it is declared
>in unistd.h instead (the getopt function is in libc). Actually I also have the
>libgnugetopt port installed, which _does_ have a getopt.h, but it is in
>/usr/local/include and is also not detected.
>
>Fixing this properly is beyond my level of autoconf experience...
>
>Regards,
>
>Brian Candler.