试图编译crosstool-ng-1.20.0

时间:2015-03-02 19:22:37

标签: cross-compiling toolchain crosstool-ng

我第一次尝试./configure crosstool-ng看起来像这样:

 iMac:crosstool-ng-1.20.0 rand$ ./configure --prefix=/opt/local 
--with-libtool=/opt/local/bin/glibtool
--with-libtoolize=/opt/local/bin/glibtoolize
--with-objcopy=/opt/local/bin/gobjcopy
--with-objdump=/opt/local/bin/gobjdump
--with-readelf=/opt/local/bin/greadelf
--with-awk=/opt/local/bin/gawk            
--with-sed=/opt/local/bin/gsed 
--with-automake=/opt/local/bin/automake
--with-wget=/opt/local/bin/wget
--with-gcc=/opt/local/bin/gcc-mp-4.3
--with-binutils=/opt/local/bin
然后bla-bla-bla ......

checking for wget... no
configure: error: missing required tool: wget

当然,crosstool-ng确实需要wget。但它很奇怪,因为我拥有它!

iMac:crosstool-ng-1.20.0 rand$ ls -l /opt/local/bin |grep wget
-rwxr-xr-x  1 root  admin   499672 Mar  1 00:39 wget

好的,对/ usr / bin做了符号链接,这就是诀窍。我没有删除wget前缀只是为了看它是否警告我在其他地方......我是对的。

configure: WARNING: unrecognized options: --with-wget, --with-gcc, --with-binutils

所以我删除了所有无法识别的选项......

iMac:crosstool-ng-1.20.0 rand$ ./configure --prefix=/opt/local 
--with-libtool=/opt/local/bin/glibtool
--with-libtoolize=/opt/local/bin/glibtoolize
--with-objcopy=/opt/local/bin/gobjcopy
--with-objdump=/opt/local/bin/gobjdump
--with-readelf=/opt/local/bin/greadelf
--with-awk=/opt/local/bin/gawk            
--with-sed=/opt/local/bin/gsed 
--with-automake=/opt/local/bin/automake
checking build system type... x86_64-apple-darwin14.1.0
checking host system type... x86_64-apple-darwin14.1.0
checking for a BSD-compatible install... /usr/bin/install -c
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... (cached) /opt/local/bin/gsed
checking whether sed understands -r -i -e... yes
checking whether ln -s works... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... gcc -E
checking for ranlib... ranlib
checking for gperf... gperf
checking for absolute path to gperf... /usr/bin/gperf
checking for bison... bison
checking for flex... flex
checking for makeinfo... makeinfo
checking for cut... cut
checking for stat... stat
checking for readlink... readlink
checking for wget... wget
checking for tar... tar
checking for gzip... gzip
checking for bzip2... bzip2
checking for patch... /usr/bin/patch
checking for bash >= 3.1... /bin/bash
checking for GNU awk... (cached) /opt/local/bin/gawk
checking for GNU make >= 3.80... /usr/bin/make
checking whether /usr/bin/make sets $(MAKE)... yes
checking for make 3.81... yes
checking for GNU libtool >= 1.5.26... (cached) /opt/local/bin/glibtool
checking for GNU libtoolize >= 1.5.26... (cached) /opt/local/bin/glibtoolize
checking for GNU automake >= 1.10... (cached) /opt/local/bin/automake
checking for xz... no
checking for lzma... no
checking for cvs... no
checking for svn... svn
checking for inline... inline
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible realloc... yes
checking for size_t... yes
checking for working alloca.h... yes
checking for alloca... yes
checking libintl.h usability... no
checking libintl.h presence... no
checking for libintl.h... no
checking ncurses/ncurses.h usability... no
checking ncurses/ncurses.h presence... no
checking for ncurses/ncurses.h... no
checking ncurses/curses.h usability... no
checking ncurses/curses.h presence... no
checking for ncurses/curses.h... no
checking ncursesw/curses.h usability... no
checking ncursesw/curses.h presence... no
checking for ncursesw/curses.h... no
checking ncurses.h usability... yes
checking ncurses.h presence... yes
checking for ncurses.h... yes
checking for library containing initscr... -lncurses
configure: creating ./config.status
config.status: creating Makefile

......瞧。似乎所有问题都消失了(?)

iMac:crosstool-ng-1.20.0 rand$ make
  SED    'ct-ng'
  SED    'scripts/crosstool-NG.sh'
  SED    'scripts/saveSample.sh'
  SED    'scripts/showTuple.sh'
  GEN    'config/configure.in'
  GEN    'paths.mk'
  GEN    'paths.sh'
  DEP    'nconf.gui.dep'
  DEP    'nconf.dep'
  DEP    'lxdialog/yesno.dep'
  DEP    'lxdialog/util.dep'
  DEP    'lxdialog/textbox.dep'
  DEP    'lxdialog/menubox.dep'
  DEP    'lxdialog/inputbox.dep'
  DEP    'lxdialog/checklist.dep'
  DEP    'mconf.dep'
  DEP    'conf.dep'
  BISON  'zconf.tab.c'
  GPERF  'zconf.hash.c'
  LEX    'lex.zconf.c'
  DEP    'zconf.tab.dep'
  CC     'zconf.tab.o'
In file included from zconf.tab.c:234:
./zconf.hash.c:177:8: warning: implicit declaration of function 'offsetof' is invalid in C99 [-Wimplicit-function-declaration]
      {offsetof(struct kconf_id_strings_t, kconf_id_strings_str2),              T_ON,           TF_PARAM},
       ^
./zconf.hash.c:177:17: error: expected expression
      {offsetof(struct kconf_id_strings_t, kconf_id_strings_str2),              T_ON,           TF_PARAM},
                ^
./zconf.hash.c:178:17: error: expected expression
      {offsetof(struct kconf_id_strings_t, kconf_id_strings_str3),              T_OPT_ENV,      TF_OPTION},
                ^
./zconf.hash.c:180:17: error: expected expression
      {offsetof(struct kconf_id_strings_t, kconf_id_strings_str5),              T_ENDIF,        TF_COMMAND},
                ^
./zconf.hash.c:181:17: error: expected expression
      {offsetof(struct kconf_id_strings_t, kconf_id_strings_str6),              T_OPTION,       TF_COMMAND},
                ^
./zconf.hash.c:182:17: error: expected expression
      {offsetof(struct kconf_id_strings_t, kconf_id_strings_str7),      T_ENDMENU,      TF_COMMAND},
                ^
./zconf.hash.c:183:17: error: expected expression
      {offsetof(struct kconf_id_strings_t, kconf_id_strings_str8),      T_OPTIONAL,     TF_COMMAND},
                ^
./zconf.hash.c:184:17: error: expected expression
      {offsetof(struct kconf_id_strings_t, kconf_id_strings_str9),      T_ENDCHOICE,    TF_COMMAND},
                ^
./zconf.hash.c:185:17: error: expected expression
      {offsetof(struct kconf_id_strings_t, kconf_id_strings_str10),             T_RANGE,        TF_COMMAND},
                ^
./zconf.hash.c:186:17: error: expected expression
      {offsetof(struct kconf_id_strings_t, kconf_id_strings_str11),             T_CHOICE,       TF_COMMAND},
                ^
./zconf.hash.c:187:17: error: expected expression
      {offsetof(struct kconf_id_strings_t, kconf_id_strings_str12),     T_DEFAULT,      TF_COMMAND, S_UNKNOWN},
                ^
./zconf.hash.c:188:17: error: expected expression
      {offsetof(struct kconf_id_strings_t, kconf_id_strings_str13),     T_DEFAULT,      TF_COMMAND, S_BOOLEAN},
                ^
./zconf.hash.c:189:17: error: expected expression
      {offsetof(struct kconf_id_strings_t, kconf_id_strings_str14),             T_HELP,         TF_COMMAND},
                ^
./zconf.hash.c:191:17: error: expected expression
      {offsetof(struct kconf_id_strings_t, kconf_id_strings_str16),             T_CONFIG,       TF_COMMAND},
                ^
./zconf.hash.c:192:17: error: expected expression
      {offsetof(struct kconf_id_strings_t, kconf_id_strings_str17),     T_DEFAULT,      TF_COMMAND, S_TRISTATE},
                ^
./zconf.hash.c:193:17: error: expected expression
      {offsetof(struct kconf_id_strings_t, kconf_id_strings_str18),             T_TYPE,         TF_COMMAND, S_HEX},
                ^
./zconf.hash.c:194:17: error: expected expression
      {offsetof(struct kconf_id_strings_t, kconf_id_strings_str19),     T_OPT_DEFCONFIG_LIST,TF_OPTION},
                ^
./zconf.hash.c:196:17: error: expected expression
      {offsetof(struct kconf_id_strings_t, kconf_id_strings_str22),             T_IF,           TF_COMMAND|TF_PARAM},
                ^
./zconf.hash.c:197:17: error: expected expression
      {offsetof(struct kconf_id_strings_t, kconf_id_strings_str23),             T_TYPE,         TF_COMMAND, S_INT},
                ^
./zconf.hash.c:199:17: error: expected expression
      {offsetof(struct kconf_id_strings_t, kconf_id_strings_str27),     T_OPT_MODULES,  TF_OPTION},
                ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
make[2]: *** [zconf.tab.o] Error 1
make[1]: *** [build-lib-kconfig] Error 2
make: *** [build] Error 2

现在我无法解决错误。 Mb gcc?仅仅因为wget只在/ usr / bin中被识别,我认为配置脚本也不能识别gcc前缀,它在/ usr / bin中查找,我的默认编译器是:

 iMac:crosstool-ng-1.20.0 rand$ gcc --version
 Configured with: --    prefix=/Applications/Xcode.app/Contents/Developer/usr 
 --with-gxx-include-dir=/usr/include/c++/4.2.1
 Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)
 Target: x86_64-apple-darwin14.1.0
 Thread model: posix

但不是/ opt / local / bin

中的那个
iMac:crosstool-ng-1.20.0 rand$ /opt/local/bin/gcc-mp-4.3 --version
gcc-mp-4.3 (MacPorts gcc43 4.3.6_10) 4.3.6
Copyright (C) 2008 Free Software Foundation, Inc.

有什么想法吗?

1 个答案:

答案 0 :(得分:3)

这是因为offsetof()在OS X上需要stddef.h标题。这里有一个补丁,可以确保它包含在内:

https://sourceware.org/ml/crossgcc/2014-10/msg00021.html

为了将来参考,补丁是:

diff --git a/kconfig/zconf.gperf b/kconfig/zconf.gperf
index c9e690e..d758a2a 100644
--- a/kconfig/zconf.gperf
+++ b/kconfig/zconf.gperf
@@ -7,6 +7,15 @@
 %pic
 %struct-type

+%{
+# ifndef offsetof
+#  include <stddef.h>
+#  ifndef offsetof
+#   define offsetof(st, m) ((size_t)(&((st *)0)->m))
+#  endif
+# endif
+%}
+
 struct kconf_id;

 static struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);

使用patch -p1申请:)