【已解决】cygwin下编译crosstool-ng在Building C library时出错:../wcsmbs/uchar.h:47:5: error: #error "<uchar.h> requires ISO C11 mode"

【问题】

折腾:

【记录】cygwin下在针对arm920t去ct-ng menuconfig配置后去ct-ng build去编译

期间,在

Installing C library

Building C library

阶段,出错了:

[INFO ]  =================================================================
[INFO ]  Installing C library
[EXTRA]    Configuring C library
[EXTRA]    Building C library
[ERROR]    ../wcsmbs/uchar.h:47:5: error: #error "<uchar.h> requires ISO C11 mode"
[ERROR]    ../wcsmbs/uchar.h:52: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'char16_t'
[ERROR]    ../wcsmbs/uchar.h:53: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'char32_t'
[ERROR]    ../wcsmbs/uchar.h:61: error: expected ')' before '*' token
[ERROR]    ../wcsmbs/uchar.h:66: error: expected declaration specifiers or '...' before 'char16_t'
[ERROR]    ../wcsmbs/uchar.h:73: error: expected ')' before '*' token
[ERROR]    ../wcsmbs/uchar.h:78: error: expected declaration specifiers or '...' before 'char32_t'
[ERROR]    c16rtomb.c:27: error: expected declaration specifiers or '...' before 'char16_t'
[ERROR]    c16rtomb.c:31: error: 'c16' undeclared (first use in this function)
[ERROR]    c16rtomb.c:31: error: (Each undeclared identifier is reported only once
[ERROR]    c16rtomb.c:31: error: for each function it appears in.)
[ERROR]    make[3]: *** [/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-final/wcsmbs/c16rtomb.o] Error 1
[ERROR]    ../wcsmbs/uchar.h:47:5: error: #error "<uchar.h> requires ISO C11 mode"
[ERROR]    ../wcsmbs/uchar.h:52: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'char16_t'
[ERROR]    ../wcsmbs/uchar.h:53: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'char32_t'
[ERROR]    ../wcsmbs/uchar.h:61: error: expected ')' before '*' token
[ERROR]    ../wcsmbs/uchar.h:66: error: expected declaration specifiers or '...' before 'char16_t'
[ERROR]    ../wcsmbs/uchar.h:73: error: expected ')' before '*' token
[ERROR]    ../wcsmbs/uchar.h:78: error: expected declaration specifiers or '...' before 'char32_t'
[ERROR]    mbrtoc16.c:37: error: expected ')' before '*' token
[ERROR]    make[3]: *** [/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-final/wcsmbs/mbrtoc16.o] Error 1
[ERROR]    make[2]: *** [wcsmbs/subdir_lib] Error 2
[ERROR]    make[1]: *** [all] Error 2
[ERROR]  -
[ERROR]  >>
[ERROR]  >>  Build failed in step 'Installing C library'
[ERROR]  >>        called in step '(top-level)'
[ERROR]  >>
[ERROR]  >>  Error happened in: CT_DoExecLog[scripts/functions@257]
[ERROR]  >>        called from: do_libc_backend_once[scripts/build/libc/glibc-eglibc.sh-common@441]
[ERROR]  >>        called from: do_libc_backend[scripts/build/libc/glibc-eglibc.sh-common@143]
[ERROR]  >>        called from: do_libc[scripts/build/libc/glibc-eglibc.sh-common@65]
[ERROR]  >>        called from: main[scripts/crosstool-NG.sh@632]
         /

Current command:
  'make' '-j4' '-l' 'all'
exited with error code: 2
Please fix it up and finish by exiting the shell with one of these values:
    1  fixed, continue with next build command
    2  repeat this build command
    3  abort build

ct-ng:/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-final>

如图:

wcsmbs uchar.h error error uchar.h requires ISO C11 mode

即:

../wcsmbs/uchar.h:47:5: error: #error "<uchar.h> requires ISO C11 mode"

【解决过程】

1.去看看对应的log文件:

E:\dev_install_root\cygwin\home\develop\crosstool-ng\crosstool-ng-1.18.0_build\build.log

中的内容是:

/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-final/wcsmbs/isoc99_wscanf.o -MD -MP -MF /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-final/wcsmbs/isoc99_wscanf.o.dt -MT /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-final/wcsmbs/isoc99_wscanf.o
[ALL  ]    arm-arm920t-linux-gnueabi-gcc     isoc99_vwscanf.c -c -std=gnu99 -fgnu89-inline  -O -O2 -U_FORTIFY_SOURCE -Wall -Winline -Wwrite-strings -fmerge-all-constants -frounding-math -march=armv4t -mlittle-endian -msoft-float -mtune=arm920t -Wstrict-prototypes   -fexceptions      -I../include -I/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-final/wcsmbs -I/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-final -I../ports/sysdeps/unix/sysv/linux/arm/nptl -I../ports/sysdeps/unix/sysv/linux/arm -I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -I../sysdeps/pthread -I../ports/sysdeps/unix/sysv/linux -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/inet -I../nptl/sysdeps/unix/sysv -I../ports/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../ports/sysdeps/unix/arm -I../nptl/sysdeps/unix -I../ports/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -I../ports/sysdeps/arm/nptl -I../ports/sysdeps/arm -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754 -I../sysdeps/generic -I../nptl -I../ports  -I.. -I../libio -I. -nostdinc -isystem /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/buildtools/lib/gcc/arm-arm920t-linux-gnueabi/4.3.2/include -isystem /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/buildtools/lib/gcc/arm-arm920t-linux-gnueabi/4.3.2/include-fixed -isystem /home/develop/crosstool-ng/x-tools/arm-arm920t-linux-gnueabi/arm-arm920t-linux-gnueabi/sysroot/usr/include  -D_LIBC_REENTRANT -include ../include/libc-symbols.h       -D_IO_MTSAFE_IO -o /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-final/wcsmbs/isoc99_vwscanf.o -MD -MP -MF /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-final/wcsmbs/isoc99_vwscanf.o.dt -MT /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-final/wcsmbs/isoc99_vwscanf.o
[ALL  ]    In file included from ../include/uchar.h:1,
[ALL  ]                     from c16rtomb.c:19:
[ERROR]    ../wcsmbs/uchar.h:47:5: error: #error "<uchar.h> requires ISO C11 mode"
[ALL  ]    In file included from ../include/uchar.h:1,
[ALL  ]                     from c16rtomb.c:19:
[ERROR]    ../wcsmbs/uchar.h:52: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'char16_t'
[ERROR]    ../wcsmbs/uchar.h:53: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'char32_t'
[ERROR]    ../wcsmbs/uchar.h:61: error: expected ')' before '*' token
[ERROR]    ../wcsmbs/uchar.h:66: error: expected declaration specifiers or '...' before 'char16_t'
[ERROR]    ../wcsmbs/uchar.h:73: error: expected ')' before '*' token
[ERROR]    ../wcsmbs/uchar.h:78: error: expected declaration specifiers or '...' before 'char32_t'
[ERROR]    c16rtomb.c:27: error: expected declaration specifiers or '...' before 'char16_t'
[ALL  ]    c16rtomb.c: In function 'c16rtomb':
[ERROR]    c16rtomb.c:31: error: 'c16' undeclared (first use in this function)
[ERROR]    c16rtomb.c:31: error: (Each undeclared identifier is reported only once
[ERROR]    c16rtomb.c:31: error: for each function it appears in.)
[ERROR]    make[3]: *** [/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-final/wcsmbs/c16rtomb.o] Error 1
[ALL  ]    make[3]: *** Waiting for unfinished jobs....
[ALL  ]    In file included from ../include/uchar.h:1,
[ALL  ]                     from mbrtoc16.c:23:
[ERROR]    ../wcsmbs/uchar.h:47:5: error: #error "<uchar.h> requires ISO C11 mode"
[ALL  ]    In file included from ../include/uchar.h:1,
[ALL  ]                     from mbrtoc16.c:23:
[ERROR]    ../wcsmbs/uchar.h:52: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'char16_t'
[ERROR]    ../wcsmbs/uchar.h:53: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'char32_t'
[ERROR]    ../wcsmbs/uchar.h:61: error: expected ')' before '*' token
[ERROR]    ../wcsmbs/uchar.h:66: error: expected declaration specifiers or '...' before 'char16_t'
[ERROR]    ../wcsmbs/uchar.h:73: error: expected ')' before '*' token
[ERROR]    ../wcsmbs/uchar.h:78: error: expected declaration specifiers or '...' before 'char32_t'
[ERROR]    mbrtoc16.c:37: error: expected ')' before '*' token
[ERROR]    make[3]: *** [/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-final/wcsmbs/mbrtoc16.o] Error 1
[ALL  ]    make[3]: Leaving directory `/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/eglibc-2_17/wcsmbs'
[ERROR]    make[2]: *** [wcsmbs/subdir_lib] Error 2
[ALL  ]    make[2]: Leaving directory `/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/eglibc-2_17'
[ERROR]    make[1]: *** [all] Error 2
[ALL  ]    make[1]: Leaving directory `/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/build/build-libc-final'
[ERROR]  
[ERROR]  >>
[ERROR]  >>  Build failed in step 'Installing C library'
[ERROR]  >>        called in step '(top-level)'
[ERROR]  >>
[ERROR]  >>  Error happened in: CT_DoExecLog[scripts/functions@257]
[ERROR]  >>        called from: do_libc_backend_once[scripts/build/libc/glibc-eglibc.sh-common@441]
[ERROR]  >>        called from: do_libc_backend[scripts/build/libc/glibc-eglibc.sh-common@143]
[ERROR]  >>        called from: do_libc[scripts/build/libc/glibc-eglibc.sh-common@65]
[ERROR]  >>        called from: main[scripts/crosstool-NG.sh@632]

2.参考:

编译安装glibc

才找到源代码,原来是:

E:\dev_install_root\cygwin\home\develop\crosstool-ng\crosstool-ng-1.18.0_build\.build\src\eglibc-2_17\include\uchar.h

其中是:

#include <wcsmbs/uchar.h>

所以去看:

E:\dev_install_root\cygwin\home\develop\crosstool-ng\crosstool-ng-1.18.0_build\.build\src\eglibc-2_17\wcsmbs

找到:

E:\dev_install_root\cygwin\home\develop\crosstool-ng\crosstool-ng-1.18.0_build\.build\src\eglibc-2_17\wcsmbs\uchar.h

看到:

#if defined __GNUC__ && !defined __USE_ISOCXX11
/* Define the 16-bit and 32-bit character types.  Use the information
   provided by the compiler.  */
# if !defined __CHAR16_TYPE__ || !defined __CHAR32_TYPE__
#  if defined __STDC_VERSION__ && __STDC_VERSION__ < 201000L
#   error "<uchar.h> requires ISO C11 mode"
#  else
#   error "definitions of __CHAR16_TYPE__ and/or __CHAR32_TYPE__ missing"
#  endif
# endif
typedef __CHAR16_TYPE__ char16_t;
typedef __CHAR32_TYPE__ char32_t;
#endif

继续参考:

编译安装glibc

去看看自己的gcc的版本:

Administrator@PC-20130611GART /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/buildtools/bin
$ ./arm-arm920t-linux-gnueabi-gcc
arm-arm920t-linux-gnueabi-gcc.exe        arm-arm920t-linux-gnueabi-gcc-4.3.2.exe  arm-arm920t-linux-gnueabi-gccbug

Administrator@PC-20130611GART /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/buildtools/bin
$ ./arm-arm920t-linux-gnueabi-gcc --version
arm-arm920t-linux-gnueabi-gcc (crosstool-NG 1.18.0) 4.3.2
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Administrator@PC-20130611GART /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/buildtools/bin
$ ./arm-arm920t-linux-gnueabi-gcc -v
Using built-in specs.
Target: arm-arm920t-linux-gnueabi
Configured with: /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/gcc-4.3.2/configure --build=i686-build_pc-cygwin --host=i686-build_pc-cygwin --target=arm-arm920t-linux-gnueabi --prefix=/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/buildtools --with-local-prefix=/home/develop/crosstool-ng/x-tools/arm-arm920t-linux-gnueabi/arm-arm920t-linux-gnueabi/sysroot --disable-libmudflap --with-sysroot=/home/develop/crosstool-ng/x-tools/arm-arm920t-linux-gnueabi/arm-arm920t-linux-gnueabi/sysroot --enable-shared --with-pkgversion='crosstool-NG 1.18.0' --with-arch=armv4t --with-tune=arm920t --with-float=soft --enable-__cxa_atexit --with-gmp=/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/buildtools --with-mpfr=/home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/buildtools --enable-target-optspace --disable-libgomp --disable-libmudflap --disable-nls --disable-multilib --enable-languages=c
Thread model: posix
gcc version 4.3.2 (crosstool-NG 1.18.0)

结果看不到什么c99或c11。

3.参考:

Commit 4efeffc1d583597e4f52985b9747269e47b754e2 breaks trunk for i386and x86_64 on older GCCs.

提到了此问题。

看到其提到了gcc,所以顺带看了看当前cygwin下的gcc:

Administrator@PC-20130611GART /home/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-arm920t-linux-gnueabi/buildtools/bin
$ gcc -v
使用内建 specs。
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-cygwin/4.5.3/lto-wrapper.exe
目标:i686-pc-cygwin
配置为:/gnu/gcc/releases/respins/4.5.3-3/gcc4-4.5.3-3/src/gcc-4.5.3/configure --srcdir=/gnu/gcc/releases/respins/4.5.3-3/gcc4-4.5.3-3/src/gcc-4.5.3 --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --datadir=/usr/share --localstatedir=/var --sysconfdir=/etc --datarootdir=/usr/share --docdir=/usr/share/doc/gcc4 -C --datadir=/usr/share --infodir=/usr/share/info --mandir=/usr/share/man -v --with-gmp=/usr --with-mpfr=/usr --enable-bootstrap --enable-version-specific-runtime-libs --libexecdir=/usr/lib --enable-static --enable-shared --enable-shared-libgcc --disable-__cxa_atexit --with-gnu-ld --with-gnu-as --with-dwarf2 --disable-sjlj-exceptions --enable-languages=ada,c,c++,fortran,java,lto,objc,obj-c++ --enable-graphite --enable-lto --enable-java-awt=gtk --disable-symvers --enable-libjava --program-suffix=-4 --enable-libgomp --enable-libssp --enable-libada --enable-threads=posix --with-arch=i686 --with-tune=generic --enable-libgcj-sublibs CC=gcc-4 CXX=g++-4 CC_FOR_TARGET=gcc-4 CXX_FOR_TARGET=g++-4 GNATMAKE_FOR_TARGET=gnatmake GNATBIND_FOR_TARGET=gnatbind --with-ecj-jar=/usr/share/java/ecj.jar
线程模型:posix
gcc 版本 4.5.3 (GCC)

我这里是4.5.3的。

然后此刻才注意到,上面的:

arm-arm920t-linux-gnueabi-gcc

gcc version 4.3.2

的,其不支持c11。

但是不懂。

参考了:

编译安装glibc

有点看懂了:

其是把glibc-2.16.0换成glibc-2.15,以解决的问题。

4.所以,我此处,应该是:

把当前的eglibc从2.17,换成更低的版本,才对。

所以,去把eglibc,换为2.16试试:

    C library (eglibc)  --->
    eglibc version (2_16)  --->

然后ct-ng clean后,重新编译:

5.不过还没编译,先去:

【已解决】弄明白哪个版本的gcc才支持c11

所以明白了:

估计glibc 2.16,也是要c11的,所以此处,还是把对应的eglibc,也弄到更低的版本,比如2.15,而不要选2.16了。

所以去ct-ng menuconfig,设置为:

C library (eglibc)  —>

eglibc version (2_15)  —>

然后再去重新编译。

6.没编译之前,再去看看,是不是还有其他支持c11的gcc版本可以选择,

然后发现,其实也是有4.7之后的gcc可供选择的。

不过,暂时还是不去换gcc了。

还是继续上面的,用

gcc version (4.3.2)

然后加上:

eglibc version (2_15) 

去编译看看。

最终,算是解决了此处的:

../wcsmbs/uchar.h:47:5: error: #error "<uchar.h> requires ISO C11 mode"

的错误。

 

【总结】

此处,在cygwin下编译crosstool-ng,在:

Installing C library

Building C library

阶段,出现:

../wcsmbs/uchar.h:47:5: error: #error "<uchar.h> requires ISO C11 mode"

的错误的原因是:

此处crosstool-ng中的配置是:

gcc 4.3.2

eglibc 2.17

而eglibc 2.17(和glibc的2.17类似),是支持c11版本的c库的,所以其头文件:

crosstool-ng-1.18.0_build\.build\src\eglibc-2_17\wcsmbs\uchar.h

中有此版本要求:

#if defined __GNUC__ && !defined __USE_ISOCXX11
/* Define the 16-bit and 32-bit character types.  Use the information
   provided by the compiler.  */
# if !defined __CHAR16_TYPE__ || !defined __CHAR32_TYPE__
#  if defined __STDC_VERSION__ && __STDC_VERSION__ < 201000L
#   error "<uchar.h> requires ISO C11 mode"
#  else
#   error "definitions of __CHAR16_TYPE__ and/or __CHAR32_TYPE__ missing"
#  endif
# endif
typedef __CHAR16_TYPE__ char16_t;
typedef __CHAR32_TYPE__ char32_t;
#endif

要求必须支持c11。

而此处的gcc 4.3.2,是不支持c11的。

对应的是,至少4.7的gcc才支持c11的。

所以:

要么把gcc换成4.7或更高版本;

要么把eglibc换成(不需要强制要求支持c11的)低版本,比如eglibc 2.15或更低的版本

此处,就选择了后者:

把eglibc,换成,无需要求c11的,2.15版本的,就可以了。

对应的crosstool-ng中的配置如下:

C compiler (gcc)  —>

gcc version (4.3.2)  —>

C library (eglibc)  —>

eglibc version (2_15)  —>

 


不过又出现其他错误:

【未解决】cygwin下编译crosstool-ng在Installing C library的Building C library出错:rpc/types.h:73:18: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘u_char’



发表评论

电子邮件地址不会被公开。 必填项已用*标注

无觅相关文章插件,快速提升流量