最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】Cygwin下make编译Buildroot出错:./stdio.h:477:66: error: missing binary operator before token "("

Buildroot crifan 9640浏览 0评论

【问题】

折腾:

【记录】在Cygwin上用Buildroot为xscale建立交叉工具链

期间,编译出错:

/usr/bin/make  all-am
make[4]: Entering directory `/home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-m4-1.4.16/lib'
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT gl_avltree_oset.o -MD -MP -MF .deps/gl_avltree_oset.Tpo -c -o gl_avltree_oset.o gl_avltree_oset.c
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT c-ctype.o -MD -MP -MF .deps/c-ctype.Tpo -c -o c-ctype.o c-ctype.c
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT c-stack.o -MD -MP -MF .deps/c-stack.Tpo -c -o c-stack.o c-stack.c
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT clean-temp.o -MD -MP -MF .deps/clean-temp.Tpo -c -o clean-temp.o clean-temp.c
In file included from clean-temp.h:22:0,
                 from clean-temp.c:23:
./stdio.h:477:66: error: missing binary operator before token "("
mv -f .deps/c-ctype.Tpo .deps/c-ctype.Po
make[4]: *** [clean-temp.o] Error 1
make[4]: *** Waiting for unfinished jobs....
mv -f .deps/c-stack.Tpo .deps/c-stack.Po
mv -f .deps/gl_avltree_oset.Tpo .deps/gl_avltree_oset.Po
make[4]: Leaving directory `/home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-m4-1.4.16/lib'
make[3]: *** [all] Error 2
make[3]: Leaving directory `/home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-m4-1.4.16/lib'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-m4-1.4.16'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-m4-1.4.16'
make: *** [/home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-m4-1.4.16/.stamp_built] Error 2

如图:

stdio.h error missing binary operator before token parethesis

即:

./stdio.h:477:66: error: missing binary operator before token "("

【解决过程】

1.去看一下对应的文件:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\output\build\host-m4-1.4.16\lib\clean-temp.c

其包含了:

/* Specification.  */
#include "clean-temp.h"

再去看看:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\output\build\host-m4-1.4.16\lib\clean-temp.h

其包含了:

#include <stdio.h>

2.看了看输出的:

-I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include

中,实际上此处

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\output\host\usr

下面根本没有include文件夹。

3.上面所包含的标准的stdio.h

此处,要找到,到底在哪里。

找到2个:

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ find /usr/include/ -name stdio.h
/usr/include/stdio.h
/usr/include/sys/stdio.h

第一个

/usr/include/stdio.h

对应的是:

D:\tmp\tmp_dev_root\cgwin\usr\include\stdio.h

其中477行是注释:

first studio.h 477 line is comment

第二个:

/usr/include/sys/stdio.h

对应的是:

D:\tmp\tmp_dev_root\cgwin\usr\include\sys\stdio.h

一共只有43行,没有447行。

所以肯定不是这个。

基本确定就是:

D:\tmp\tmp_dev_root\cgwin\usr\include\stdio.h

的问题。

4.看起来,像是和cygwin有关,但是不知道如何修改。。。

5.改了半天stdio.h也还是不行。

6.试试,添加定义cygwin,去试试:

make -D__CYGWIN__

结果不识别:

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ make -D__CYGWIN__
make: invalid option -- D
make: invalid option -- _
make: invalid option -- _
Usage: make [options] [target] ...
Options:
  -b, -m                      Ignored for compatibility.
  -B, --always-make           Unconditionally make all targets.
  -C DIRECTORY, --directory=DIRECTORY
                              Change to DIRECTORY before doing anything.
  -d                          Print lots of debugging information.
  --debug[=FLAGS]             Print various types of debugging information.
  -e, --environment-overrides
                              Environment variables override makefiles.
  -f FILE, --file=FILE, --makefile=FILE
                              Read FILE as a makefile.
  -h, --help                  Print this message and exit.
  -i, --ignore-errors         Ignore errors from commands.
  -I DIRECTORY, --include-dir=DIRECTORY
                              Search DIRECTORY for included makefiles.
  -j [N], --jobs[=N]          Allow N jobs at once; infinite jobs with no arg.
  -k, --keep-going            Keep going when some targets can't be made.
  -l [N], --load-average[=N], --max-load[=N]
                              Don't start multiple jobs unless load is below N.
  -L, --check-symlink-times   Use the latest mtime between symlinks and target.
  -n, --just-print, --dry-run, --recon
                              Don't actually run any commands; just print them.
  -o FILE, --old-file=FILE, --assume-old=FILE
                              Consider FILE to be very old and don't remake it.
  -p, --print-data-base       Print make's internal database.
  -q, --question              Run no commands; exit status says if up to date.
  -r, --no-builtin-rules      Disable the built-in implicit rules.
  -R, --no-builtin-variables  Disable the built-in variable settings.
  -s, --silent, --quiet       Don't echo commands.
  -S, --no-keep-going, --stop
                              Turns off -k.
  -t, --touch                 Touch targets instead of remaking them.
  -v, --version               Print the version number of make and exit.
  -w, --print-directory       Print the current directory.
  --no-print-directory        Turn off -w, even if it was turned on implicitly.
  -W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
                              Consider FILE to be infinitely new.
  --warn-undefined-variables  Warn when an undefined variable is referenced.

This program built for i686-pc-cygwin
Report bugs to <[email protected]>

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05

加上all也不行:

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ make all -D__CYGWIN__
make: invalid option -- D
make: invalid option -- _
make: invalid option -- _
Usage: make [options] [target] ...
Options:
  -b, -m                      Ignored for compatibility.
  -B, --always-make           Unconditionally make all targets.
  -C DIRECTORY, --directory=DIRECTORY
                              Change to DIRECTORY before doing anything.
  -d                          Print lots of debugging information.
  --debug[=FLAGS]             Print various types of debugging information.
  -e, --environment-overrides
                              Environment variables override makefiles.
  -f FILE, --file=FILE, --makefile=FILE
                              Read FILE as a makefile.
  -h, --help                  Print this message and exit.
  -i, --ignore-errors         Ignore errors from commands.
  -I DIRECTORY, --include-dir=DIRECTORY
                              Search DIRECTORY for included makefiles.
  -j [N], --jobs[=N]          Allow N jobs at once; infinite jobs with no arg.
  -k, --keep-going            Keep going when some targets can't be made.
  -l [N], --load-average[=N], --max-load[=N]
                              Don't start multiple jobs unless load is below N.
  -L, --check-symlink-times   Use the latest mtime between symlinks and target.
  -n, --just-print, --dry-run, --recon
                              Don't actually run any commands; just print them.
  -o FILE, --old-file=FILE, --assume-old=FILE
                              Consider FILE to be very old and don't remake it.
  -p, --print-data-base       Print make's internal database.
  -q, --question              Run no commands; exit status says if up to date.
  -r, --no-builtin-rules      Disable the built-in implicit rules.
  -R, --no-builtin-variables  Disable the built-in variable settings.
  -s, --silent, --quiet       Don't echo commands.
  -S, --no-keep-going, --stop
                              Turns off -k.
  -t, --touch                 Touch targets instead of remaking them.
  -v, --version               Print the version number of make and exit.
  -w, --print-directory       Print the current directory.
  --no-print-directory        Turn off -w, even if it was turned on implicitly.
  -W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
                              Consider FILE to be infinitely new.
  --warn-undefined-variables  Warn when an undefined variable is referenced.

This program built for i686-pc-cygwin
Report bugs to <[email protected]>

7.参考:

How to pass macro definition from “make” command line arguments (-D) to C source code?

去试试:

make CFLAGS=-D__CYGWIN__

是可以运行的,但是错误依旧。

8.关于有些地方:

Error when building bfilter

提到的,不能有:

#elif

此处是确保没有的。

9.看到:

Not compiled openldap package in gcc 4.4.0

说是要升级gcc。

让我想到了,不会是gcc的什么,特殊的bug吧。

所以,接下来,导致可以参考之前:

【已解决】Cygwin下为xscale编译Buildroot时make出错:/bin/sh: -c: line 0: syntax error near unexpected token `(‘

中的:

顺带说一下,上面的:

https://github.com/freddiechopin/NuttX/tree/master/misc/buildroot/configs

中,其实,已经帮我们弄好了一个,针对于我此处arm920t的buildroot的配置了:

arm920t-defconfig-4.2.4

arm920t-defconfig-4.3.3

arm920t-eabi-defconfig-4.5.2

有空的话,我们是可以去借用的:

减少自己的麻烦,因为别人已经编译通过了。帮忙验证过了。

不过进去看了看,其没有真正完整的buildroot的配置,但是有主要的gcc,binutils等的版本。

还是可以借鉴的。

中,去看看当前用的gcc是啥:

看到是:

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ /usr/bin/gcc --version
gcc (GCC) 4.7.3
Copyright (C) 2012 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.

 

对应的buildroot中:

make menuconfig

中的gcc也是很高的版本:

Toolchain

GCC compiler Version (gcc 4.7.x)  —> 

所以,貌似不是gcc的版本的问题。

10.再去make clean:

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ make clean
rm -rf /home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot /home/CLi/develop/buildroot/buildroot-2013.05/output/target /home/CLi/develop/buildroot/buildroot-2013.05/output/images /home/CLi/develop/buildroot/buildroot-2013.05/output/host \
                /home/CLi/develop/buildroot/buildroot-2013.05/output/stamps /home/CLi/develop/buildroot/buildroot-2013.05/output/build /home/CLi/develop/buildroot/buildroot-2013.05/output/toolchain /home/CLi/develop/buildroot/buildroot-2013.05/output/staging \
                /home/CLi/develop/buildroot/buildroot-2013.05/output/legal-info

后,重新make试试看看:

结果错误依旧:

make[4]: Entering directory `/home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-m4-1.4.16/lib'
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT gl_avltree_oset.o -MD -MP -MF .deps/gl_avltree_oset.Tpo -c -o gl_avltree_oset.o gl_avltree_oset.c
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT c-ctype.o -MD -MP -MF .deps/c-ctype.Tpo -c -o c-ctype.o c-ctype.c
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT c-stack.o -MD -MP -MF .deps/c-stack.Tpo -c -o c-stack.o c-stack.c
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT clean-temp.o -MD -MP -MF .deps/clean-temp.Tpo -c -o clean-temp.o clean-temp.c
mv -f .deps/c-ctype.Tpo .deps/c-ctype.Po
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT close-hook.o -MD -MP -MF .deps/close-hook.Tpo -c -o close-hook.o close-hook.c
mv -f .deps/gl_avltree_oset.Tpo .deps/gl_avltree_oset.Po
mv -f .deps/c-stack.Tpo .deps/c-stack.Po
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT execute.o -MD -MP -MF .deps/execute.Tpo -c -o execute.o execute.c
mv -f .deps/close-hook.Tpo .deps/close-hook.Po
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT exitfail.o -MD -MP -MF .deps/exitfail.Tpo -c -o exitfail.o exitfail.c
In file included from clean-temp.h:22:0,
                 from clean-temp.c:23:
./stdio.h:477:66: error: missing binary operator before token "("
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT fatal-signal.o -MD -MP -MF .deps/fatal-signal.Tpo -c -o fatal-signal.o fatal-signal.c
make[4]: *** [clean-temp.o] Error 1
make[4]: *** Waiting for unfinished jobs....
mv -f .deps/execute.Tpo .deps/execute.Po
mv -f .deps/fatal-signal.Tpo .deps/fatal-signal.Po
mv -f .deps/exitfail.Tpo .deps/exitfail.Po
make[4]: Leaving directory `/home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-m4-1.4.16/lib'
make[3]: *** [all] Error 2

11.另外,去搜:

host-m4-1.4.16 gcc

找到:

http://git.buildroot.net/buildroot/plain/package/m4/m4-1.4.16-no-gets.patch

Compiling error of trunk/@28863

以及:

Email Archive: armadeus-commitlog (read-only)

中的

++/opt/buildroot/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.     -O2 -I/opt/buildroot/output/host/include -I/opt/buildroot/output/host/usr/include -MT clean-temp.o -MD -MP -MF .deps/clean-temp.Tpo -c -o clean-temp.o clean-temp.c
++mv -f .deps/c-ctype.Tpo .deps/c-ctype.Po
++/opt/buildroot/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.     -O2 -I/opt/buildroot/output/host/include -I/opt/buildroot/output/host/usr/include -MT close-hook.o -MD -MP -MF .deps/close-hook.Tpo -c -o close-hook.o close-hook.c
++In file included from clean-temp.h:22:0,
++                 from clean-temp.c:23:
++./stdio.h:477:20: error 'gets' undeclared here (not in a function)
++make[4]: *** [clean-temp.o] Error 1

然后才意识到,此处的stdio.h文件,实际上是当前文件夹:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\output\build\host-m4-1.4.16\lib

下的stdio.h,所以写成:

./stdio.h

而不是

/usr/include/stdio.h

此刻,再去看看这个:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\output\build\host-m4-1.4.16\lib\stdio.h

其中477行部分的内容是:

/* It is very rare that the developer ever has full control of stdin,
   so any use of gets warrants an unconditional warning.  Assume it is
   always declared, since it is required by C89.  */
#undef gets
#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
#endif

如图:

stdio.h 477 is __GLIBC__ __UCLIBC__

所以,参考:

http://git.buildroot.net/buildroot/plain/package/m4/m4-1.4.16-no-gets.patch

发现,此时的stdio.h中的内容,是buildroot给m4打了补丁后的内容:

估计是针对于Linux系统的,此处cygwin下,不正常,所以出错了。

结果是还是无法搞懂如何修改。

12.参考:

jabss的回复

(其是参考了这个帖子:

openwrt error: ‘gets’ undeclared here (not in a function)

想要去修改:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\output\build\host-m4-1.4.16\lib\stdio.h

但是举得貌似此文件是依赖于:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\output\build\host-m4-1.4.16\lib\stdio.in.h

的,所以去把

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\output\build\host-m4-1.4.16\lib\stdio.in.h

中的:

#undef gets
#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
#endif

改为:

#undef gets
#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
/* _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead"); */
#define gets(a) fgets( a, sizeof(*(a)), stdin)
#endif

 

而关于此处的改动,是参考:

http://sourceforge.net/mailarchive/forum.php?forum_name=armadeus-commitlog&max_rows=25&style=nested&viewmonth=201208

(以及http://git.buildroot.net/buildroot/plain/package/m4/m4-1.4.16-no-gets.patch

的解释是:

Since the 2.16 release of the glibc, 'gets' is not any more defined in the gnulib.
No m4 version synchronized with gnulib since [1] has been released yet.

This patch avoids the following error occurs when building m4 <=1.4.16 on host using
a glibc >=2.16:

改好后,再去make编译试试,结果错误依旧。

估计是已经从

host-m4-1.4.16\lib\stdio.in.h

生成了

host-m4-1.4.16\lib\stdio.h

所以make中没有检测。

所以想要去去改动:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\output\build\host-m4-1.4.16\lib\stdio.h

结果发现,实际上此处,stdio.h已经改好了,应该是自动根据stdio.in.h的改动而生成的。

13.继续找原因。

还是报:

./stdio.h:477:66: error: missing binary operator before token "("

的错误,则说明是:

此处根本对于477这行:

#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)

无法识别,

好像是对于__GLIBC_PREREQ找不到定义。

14.然后搜:

__GLIBC_PREREQ

参考:

Re: PATCH: fix glibc version detection in sys_defs.h

先去改

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\output\build\host-m4-1.4.16\lib\stdio.in.h

为:

#undef gets
//#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
#if defined(__GLIBC__) && !defined(__UCLIBC__) && defined(__GLIBC_PREREQ) && !__GLIBC_PREREQ(2, 16)
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
//#define gets(a) fgets( a, sizeof(*(a)), stdin)
#endif

再去make试试,错误依旧。

15.再去改为:

#undef gets
//#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
#if defined(__GLIBC__) && !defined(__UCLIBC__) && defined(__GLIBC_PREREQ)
#if !__GLIBC_PREREQ(2, 16)
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
//#define gets(a) fgets( a, sizeof(*(a)), stdin)
#endif
#endif

再试试,终于可以继续编译了。

(先不管内部逻辑,是否有错。。。。)

log:

make[4]: Entering directory `/home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-m4-1.4.16/lib'
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT clean-temp.o -MD -MP -MF .deps/clean-temp.Tpo -c -o clean-temp.o clean-temp.c
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT freadahead.o -MD -MP -MF .deps/freadahead.Tpo -c -o freadahead.o freadahead.c
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT freading.o -MD -MP -MF .deps/freading.Tpo -c -o freading.o freading.c
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT localcharset.o -MD -MP -MF .deps/localcharset.Tpo -c -o localcharset.o localcharset.c
mv -f .deps/freading.Tpo .deps/freading.Po
mv -f .deps/freadahead.Tpo .deps/freadahead.Po
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT lock.o -MD -MP -MF .deps/lock.Tpo -c -o lock.o `test -f 'glthread/lock.c' || echo './'`glthread/lock.c
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT malloca.o -MD -MP -MF .deps/malloca.Tpo -c -o malloca.o malloca.c
mv -f .deps/clean-temp.Tpo .deps/clean-temp.Po
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT memchr2.o -MD -MP -MF .deps/memchr2.Tpo -c -o memchr2.o memchr2.c
mv -f .deps/malloca.Tpo .deps/malloca.Po
mv -f .deps/lock.Tpo .deps/lock.Po
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT gl_oset.o -MD -MP -MF .deps/gl_oset.Tpo -c -o gl_oset.o gl_oset.c
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT pipe2.o -MD -MP -MF .deps/pipe2.Tpo -c -o pipe2.o pipe2.c
mv -f .deps/memchr2.Tpo .deps/memchr2.Po
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT pipe2-safer.o -MD -MP -MF .deps/pipe2-safer.Tpo -c -o pipe2-safer.o pipe2-safer.c
mv -f .deps/localcharset.Tpo .deps/localcharset.Po
/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc -std=gnu99  -I.   -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include  -O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include -MT printf-frexp.o -MD -MP -MF .deps/printf-frexp.Tpo -c -o printf-frexp.o printf-frexp.c
mv -f .deps/pipe2.Tpo .deps/pipe2.Po
mv -f .deps/gl_oset.Tpo .deps/gl_oset.Po

 

如图:

clean temp compile ok

 

【总结】

Cygwin下make编译Buildroot出现:

./stdio.h:477:66: error: missing binary operator before token "("

的错误,

原因是:

buildroot中的host的m4-1.4.16/lib中,其下包含的stdio.h所依赖的stdio.in.h中有宏定义的判断:

#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)

但是此处,不存在__GLIBC_PREREQ这个宏,导致#if无法判断,导致出现此种错误。

解决办法:

改为,先判断该宏是否存在,再继续判断版本,即可:

#undef gets
//#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
#if defined(__GLIBC__) && !defined(__UCLIBC__) && defined(__GLIBC_PREREQ)
#if !__GLIBC_PREREQ(2, 16)
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
//#define gets(a) fgets( a, sizeof(*(a)), stdin)
#endif
#endif

【继续折腾】

1.另外,一点疑惑:

貌似参考:

Re: PATCH: fix glibc version detection in sys_defs.h

改为:

#undef gets
//#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
//#if defined(__GLIBC__) && !defined(__UCLIBC__) && defined(__GLIBC_PREREQ)
//#if !__GLIBC_PREREQ(2, 16)
#if defined(__GLIBC__) && !defined(__UCLIBC__)
#if !((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16))
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
//#define gets(a) fgets( a, sizeof(*(a)), stdin)
#endif
#endif

后续更合适些?

2.所以,此处,也去继续重新make编译,看看能否编译通过:

(为确保编译正常,先make clean后再make)

结果是,错误依旧。

因为此处的stdio.in.h会被恢复原样:

#undef gets
#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
#endif

所以,必然出错。

3.重新修改为上面的:

#undef gets
//#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
//#if defined(__GLIBC__) && !defined(__UCLIBC__) && defined(__GLIBC_PREREQ)
//#if !__GLIBC_PREREQ(2, 16)
#if defined(__GLIBC__) && !defined(__UCLIBC__)
#if !((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16))
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
//#define gets(a) fgets( a, sizeof(*(a)), stdin)
#endif
#endif

再去make试试,就可以了。

即,对于之前:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\output\build\host-m4-1.4.16\lib\stdio.in.h

的:

#undef gets
#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
#endif

有两种改法:

改法1:

#undef gets
//#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
#if defined(__GLIBC__) && !defined(__UCLIBC__) && defined(__GLIBC_PREREQ)
#if !__GLIBC_PREREQ(2, 16)
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
//#define gets(a) fgets( a, sizeof(*(a)), stdin)
#endif
#endif

改法2:

#undef gets
//#if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
//#if defined(__GLIBC__) && !defined(__UCLIBC__) && defined(__GLIBC_PREREQ)
//#if !__GLIBC_PREREQ(2, 16)
#if defined(__GLIBC__) && !defined(__UCLIBC__)
#if !((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16))
_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
//#define gets(a) fgets( a, sizeof(*(a)), stdin)
#endif
#endif

个人觉得,第二种,应该更好。因为的确去判断了__GLIBC__的版本。

至此,算是比较完整的,解决了上述问题。

转载请注明:在路上 » 【已解决】Cygwin下make编译Buildroot出错:./stdio.h:477:66: error: missing binary operator before token "("

与本文相关的文章

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (1)

  1. 😎 佩服佩服
    Lusian5年前 (2020-01-09)回复
86 queries in 0.189 seconds, using 22.32MB memory