Hi, When building grep-2.7 on a glibc system with GNU libiconv installed, the build fails with a link error:
$ ./configure --host=i686-pc-linux-gnu \ --prefix=/arch/x86-linux/gnu \ CC="gcc -m32 -march=i586" LDFLAGS="-m32" CPPFLAGS=-Wall $ make ... CCLD grep ../lib/libgreputils.a(striconv.o): In function `str_cd_iconv': /data/home-susekde3/bruno/data/build/grep-2.7/lib/striconv.c:279: undefined reference to `libiconv' /data/home-susekde3/bruno/data/build/grep-2.7/lib/striconv.c:293: undefined reference to `libiconv' /data/home-susekde3/bruno/data/build/grep-2.7/lib/striconv.c:333: undefined reference to `libiconv' ../lib/libgreputils.a(striconv.o): In function `str_iconv': /data/home-susekde3/bruno/data/build/grep-2.7/lib/striconv.c:423: undefined reference to `libiconv_open' /data/home-susekde3/bruno/data/build/grep-2.7/lib/striconv.c:438: undefined reference to `libiconv_close' /data/home-susekde3/bruno/data/build/grep-2.7/lib/striconv.c:433: undefined reference to `libiconv_close' ../lib/libgreputils.a(striconv.o): In function `mem_cd_iconv': /data/home-susekde3/bruno/data/build/grep-2.7/lib/striconv.c:57: undefined reference to `libiconv' /data/home-susekde3/bruno/data/build/grep-2.7/lib/striconv.c:76: undefined reference to `libiconv' /data/home-susekde3/bruno/data/build/grep-2.7/lib/striconv.c:106: undefined reference to `libiconv' /data/home-susekde3/bruno/data/build/grep-2.7/lib/striconv.c:138: undefined reference to `libiconv' /data/home-susekde3/bruno/data/build/grep-2.7/lib/striconv.c:152: undefined reference to `libiconv' ../lib/libgreputils.a(striconv.o):/data/home-susekde3/bruno/data/build/grep-2.7/lib/striconv.c:177: more undefined references to `libiconv' follow collect2: ld returned 1 exit status make[2]: *** [grep] Error 1 make[2]: Leaving directory `/data/bruno/build/grep-2.7/src' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/data/bruno/build/grep-2.7' make: *** [all] Error 2 The reason is that - grep uses the gnulib 'propername' module (see <http://git.savannah.gnu.org/gitweb/?p=grep.git;a=blob;f=bootstrap.conf> line 60), - this module requires linking with: $(LTLIBICONV) when linking with libtool, $(LIBICONV) otherwise - src/Makefile.am does not use $(LIBICONV). Here is a fix. $(LIBICONV) should be at the end of LDADD. Note that after applying this fix, I had to update src/Makefile.in by hand, because the automake/autoconf machinery refused to update anything, because the version of automake with which the release was packaged (automake-1.11a) is not a released version. 2010-09-23 Bruno Haible <br...@clisp.org> Fix link error on systems that have libiconv but not libintl. * src/Makefile.am (LDADD): Add $(LIBICONV). --- src/Makefile.am.bak 2010-04-04 14:22:24.000000000 +0200 +++ src/Makefile.am 2010-09-23 12:32:24.000000000 +0200 @@ -36,7 +36,9 @@ # must precede $(LIBINTL) in order to ensure we use GNU getopt. # But libgreputils.a must also follow $(LIBINTL), since libintl uses # replacement functions defined in libgreputils.a. -LDADD = libgrep.a ../lib/libgreputils.a $(LIBINTL) ../lib/libgreputils.a +LDADD = \ + libgrep.a \ + ../lib/libgreputils.a $(LIBINTL) ../lib/libgreputils.a $(LIBICONV) grep_LDADD = $(LDADD) $(LIB_PCRE) localedir = $(datadir)/locale