Gcc 在OS X上交叉编译binutils

Gcc 在OS X上交叉编译binutils,gcc,cross-compiling,toolchain,binutils,Gcc,Cross Compiling,Toolchain,Binutils,我正试图在OSX小牛上创建一个Linux Arm工具链。我在/usr/local/GCC-4.8.1-for-linux64/bin/中有GCC 4.8.1二进制文件,这是我用来为binutils生成配置脚本的命令: $../binutils-2.23.2/configure--target=arm未知linux--prefix=$prefix--bindir=/usr/local/gcc-4.8.1-for-linux64/bin/ 运行“全部生成”时,我遇到以下错误: gcc -DHAVE_

我正试图在OSX小牛上创建一个Linux Arm工具链。我在
/usr/local/GCC-4.8.1-for-linux64/bin/
中有GCC 4.8.1二进制文件,这是我用来为binutils生成配置脚本的命令:

$../binutils-2.23.2/configure--target=arm未知linux--prefix=$prefix--bindir=/usr/local/gcc-4.8.1-for-linux64/bin/

运行“全部生成”时,我遇到以下错误:

gcc -DHAVE_CONFIG_H -I. -I../../binutils-2.23.2/binutils  -I. -I../../binutils-2.23.2/binutils -I../bfd -I../../binutils-2.23.2/binutils/../bfd -I../../binutils-2.23.2/binutils/../include -I./../intl -DLOCALEDIR="\"/usr/local/arm/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation  -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror -g -O2 -MT readelf.o -MD -MP -MF .deps/readelf.Tpo -c -o readelf.o ../../binutils-2.23.2/binutils/readelf.c
../../binutils-2.23.2/binutils/readelf.c:9046:20: error: adding 'int' to a
      string does not append to the string [-Werror,-Wstring-plus-int]
    fputs ("     " + n, stdout);
           ~~~~~~~~^~~
../../binutils-2.23.2/binutils/readelf.c:9046:20: note: use array indexing to
      silence this warning
    fputs ("     " + n, stdout);
                   ^
           &       [  ]
1 error generated.
make[4]: *** [readelf.o] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-binutils] Error 2
make: *** [all] Error 2
错误的原因是什么?如何解决


更新1 将
binutils
更新为2.24,错误已更改为

[ALL  ]    x86_64-build_apple-darwin13.0.0-gcc   -D_RPC_THREAD_SAFE_ -D_GNU_SOURCE -DIS_IN_build -include /Volumes/CrosstoolCompile/arm-unknown-linux-gnueabi/build/build-libc-startfiles/config.h rpc_sample.c         -o /Volumes/CrosstoolCompile/arm-unknown-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_sample.o -MMD -MP -MF /Volumes/CrosstoolCompile/arm-unknown-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_sample.o.dt -MT /Volumes/CrosstoolCompile/arm-unknown-linux-gnueabi/build/build-libc-startfiles/sunrpc/cross-rpc_sample.o -c
[ERROR]    rpc_scan.c:40:10: fatal error: 'libintl.h' file not found
[ALL  ]    #include <libintl.h>
[ALL  ]             ^
[ERROR]    rpc_main.c:41:10: fatal error: 'libintl.h' file not found
[ALL  ]    #include <libintl.h>
[ALL  ]             ^
[ALL  ]    In file included from rpc_clntout.c:34:
[ERROR]    ./rpc/types.h:73:9: error: unknown type name '__u_char'; did you mean 'u_char'?
[ALL  ]    typedef __u_char u_char;
[ALL  ]            ^~~~~~~~
[ALL  ]            u_char
[ALL  ]    /usr/include/sys/types.h:84:24: note: 'u_char' declared here
[ALL  ]    typedef unsigned char           u_char;
[ALL  ]                                    ^
[全部]x86_64-build_apple-darwin13.0.0-gcc-D_RPC_THREAD_SAFE_-D_GNU_SOURCE-DIS_IN_build-include/Volumes/crosstoolcile/arm unknown linux gnueabi/build/build libc startfiles/config.h RPC_sample.c-o/Volumes/crosstoolcile/arm unown linux gnueabi/build libc startfiles/sunrpc-sample.o-MMD-MP-MF/Volumes/crosstoolcomile/arm unknown linux gnueabi/build/build libc startfiles/sunrpc/cross-rpc_sample.o.dt-MT/Volumes/crosstoolcomile/arm unknown linux gnueabi/build/build libc startfiles/sunrpc/cross-rpc_sample.o-c
[错误]rpc_scan.c:40:10:致命错误:“未找到libintl.h”文件
[全部]#包括
[全部]^
[错误]rpc_main.c:41:10:致命错误:“未找到libintl.h”文件
[全部]#包括
[全部]^
rpc_clntout.c:34中包含的文件中的[全部]:
[错误]。/rpc/types.h:73:9:错误:未知的类型名'\uuu\uchar';你的意思是“你查”吗?
[全部]类型定义字符;
[全部]^~~~~~~~
[全部]u_char
[ALL]/usr/include/sys/types.h:84:24:注意:此处声明了“u_char”
[ALL]typedef unsigned char u_char;
[全部]^

未设置自定义编译器/链接器标志

使用更高版本的binutils。这种事情已经在多个地方解决了。2.24版刚刚发布

binutils更高版本中的修复程序如下所示:

fputs (&" "[n], stdout);

我想你的Mac电脑上的“gcc”真的是“叮当”。当我开始自己编译ELLCC时,正是出于这个原因,我不得不在我的clang中更新binutils。

我对更新1有一个答案:

这些类型干扰了OSX中内置的类型。您需要将此修补程序应用于glibc源中的types.h

--- types.h 2014-02-06 17:40:13.000000000 -0800
+++ types_new.h 2014-02-06 17:38:22.000000000 -0800
@@ -69,6 +69,9 @@
 #include <sys/types.h>
 #endif

+/* The system headers on Mac OS X conflict with these typedefs */
+#ifndef __APPLE__
+# error Error: should not be here if compiling under OSX.
 #ifndef __u_char_defined
 typedef __u_char u_char;
 typedef __u_short u_short;
@@ -84,6 +87,7 @@
 typedef __caddr_t caddr_t;
 # define __daddr_t_defined
 #endif
+#endif

 #include <sys/time.h>
 #include <sys/param.h>
关于整个过程,可以在我的网站上找到更多信息


干杯

我使用的是
crosstool ng
,最新版本的
binutil
是2.23I。我验证了您正在使用clang进行编译。这是一条叮当作响的错误消息。很抱歉,
crosstool ng
是使用binutils 2.22的。已将我的计算机上的binutils更新为2.24,并出现上述新错误。看起来您已经解决了binutils问题,并已开始构建eglibc。我不能帮你,因为我从来没有用过eglibc。ELLCC使用musl作为其标准C库。非常感谢您的建议@RichardPennington,只是想澄清一下,您如何判断使用了eglibc?我一直在crosstool ng中选择glibc。这只是一个猜测。我在谷歌上搜索了rpc_scan.c,它与eglibc有关。我很可能错了。重要的是你已经超越了比努蒂尔斯。
/Volumes/{your case sensitive image}/.build/src/eglibc-2_17/sunrpc/rpc