【发布时间】:2015-11-22 22:15:52
【问题描述】:
在这里使用命令行在 OS X 10.11.1 上构建 GCC(最新版本):
../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
完全按照构建说明进行操作,但出现此错误:
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
(完整的日志可在https://gist.github.com/3cb5d044533e657f4add 获得。)
在调查gcc/Makefile 之后,似乎BUILD_CPPLIB 变量不包含$(LIBICONV),因为它在错误发生时处于stage1 引导程序中。相关部分前面有
# 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.
但很明显,build/genmatch 的 stage1 构建正在引用 libcpp,它使用来自 libiconv 的符号。所以这里有些不对劲。
我该如何解决?
【问题讨论】:
-
是否有特殊原因需要从头开始构建它?如果没有,那么您可以从例如安装最新的 gcc。 Homebrew?
-
我正在尝试破解它。
-
好的 - 在这种情况下,祝你好运!
-
哈,没错。我之前确实看过自制公式,主要区别似乎是我的构建是使用 clang 编译器系统来引导的。
-
您可以在Install GNU GCC on Mac 看到我上次报告的技术。从那时起,我使用类似的技术在 Mac OS X 10.11 上构建并安装了 GCC 5.2.0,但库版本略有升级。 OTOH,我不得不避免使用最新版本的 GMP(6.0.0a 不起作用;5.1.3 很好)和 ISL(0.14 还可以,但 0.15 不行)。我仍然使用 GCC 源目录中的 Cloog、GMP、ISL、MPC、MPFR 的源代码进行构建。我最近在 GCC 源目录之外的那些方面没有成功。