libiconv problem on OS X

Alexander Regueiro alexreg@gmail.com
Sun Nov 22 01:37:00 GMT 2015


Building GCC (latest revision) on OS X 10.11.1 here, using the command line:

../gccx/configure --with-gmp="/opt/local" --with-mpfr="/opt/local" --with-mpc="/opt/local" --with-libiconv-prefix="/opt/local" --with-pkgversion="GCCX" --program-transform-name='s/^gcc$/gccx/; s/^g++$/g++x/' --enable-languages=c

Followed build instructions exactly, and getting this error:

g++ -std=gnu++98   -g  -DIN_GCC    -fno-strict-aliasing -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format -Wmissing-format-attribute -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common  -DHAVE_CONFIG_H -DGENERATOR_FILE -fno-PIE -Wl,-no_pie   -o build/genmatch \
	    build/genmatch.o ../build-x86_64-apple-darwin15.0.0/libcpp/libcpp.a build/errors.o build/vec.o build/hash-table.o ../build-x86_64-apple-darwin15.0.0/libiberty/libiberty.a
Undefined symbols for architecture x86_64:
  "_iconv", referenced from:
      convert_using_iconv(void*, unsigned char const*, unsigned long, _cpp_strbuf*) in libcpp.a(charset.o)
     (maybe you meant: __Z14cpp_init_iconvP10cpp_reader, __cpp_destroy_iconv )
  "_iconv_close", referenced from:
      __cpp_destroy_iconv in libcpp.a(charset.o)
      __cpp_convert_input in libcpp.a(charset.o)
  "_iconv_open", referenced from:
      init_iconv_desc(cpp_reader*, char const*, char const*) in libcpp.a(charset.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [build/genmatch] Error 1
make[2]: *** [all-stage1-gcc] Error 2
make[1]: *** [stage1-bubble] Error 2
make: *** [all] Error 2

After investigating `gcc/Makefile`, it seems that the `BUILD_CPPLIB` variable does not include $(LIBICONV), since it is in a stage1 bootstrap at the time of the error. The relevant section is preceded by

# For stage1 and when cross-compiling use the build libcpp which is
# built with NLS disabled.  For stage2+ use the host library and
# its dependencies.

Yet clearly the stage1 build of `build/genmatch` is referencing libcpp, which uses symbols from libiconv. So something is amiss here.



More information about the Gcc-help mailing list