在 Raspberry Pi 上编译 gcc 时出错

在 Raspberry Pi 上编译 gcc 时出错

因此,在解决了之前遇到的问题之后(之前的问题在这里),我在 Raspberry 上编译 gcc 2.95.3 时遇到了一些其他问题。

这是我得到的

make bootstrap

命令。

../../gcc-2.95.3/gcc/config/arm/arm.c: In function ‘arm_override_options’:
../../gcc-2.95.3/gcc/config/arm/arm.c:286:20: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default]
../../gcc-2.95.3/gcc/config/arm/arm.c:530:17: error: lvalue required as left operand of assignment
make[2]: *** [arm.o] Error 1
make[2]: Leaving directory `/home/pi/Desktop/gcc2/gcc-2-build/gcc'
make[1]: *** [bootstrap] Error 2
make[1]: Leaving directory `/home/pi/Desktop/gcc2/gcc-2-build/gcc'
make: *** [bootstrap] Error 2

有人能帮帮我吗?我该如何编译它?


更新

更改该变量名后,出现以下错误:

In file included from /usr/include/stdlib.h:25,
                 from ../../gcc-2.95.3/gcc/libgcc2.c:41:
/usr/include/features.h:323: bits/predefs.h: No such file or directory
/usr/include/features.h:356: sys/cdefs.h: No such file or directory
/usr/include/features.h:388: gnu/stubs.h: No such file or directory
In file included from ../../gcc-2.95.3/gcc/libgcc2.c:41:
/usr/include/stdlib.h:42: bits/waitflags.h: No such file or directory
/usr/include/stdlib.h:43: bits/waitstatus.h: No such file or directory
/usr/include/stdlib.h:320: sys/types.h: No such file or directory
In file included from ../../gcc-2.95.3/gcc/libgcc2.c:42:
/usr/include/unistd.h:203: bits/posix_opt.h: No such file or directory
/usr/include/unistd.h:207: bits/environments.h: No such file or directory
/usr/include/unistd.h:218: bits/types.h: No such file or directory
In file included from ../../gcc-2.95.3/gcc/libgcc2.c:42:
/usr/include/unistd.h:606: bits/confname.h: No such file or directory
make[4]: *** [libgcc2.a] Error 1
make[4]: Leaving directory `/home/pi/Desktop/gcc2/gcc-2-build/gcc'
make[3]: *** [stmp-multilib-sub] Error 2
make[3]: Leaving directory `/home/pi/Desktop/gcc2/gcc-2-build/gcc'
make[2]: *** [stmp-multilib] Error 1
make[2]: Leaving directory `/home/pi/Desktop/gcc2/gcc-2-build/gcc'
make[1]: *** [bootstrap] Error 2
make[1]: Leaving directory `/home/pi/Desktop/gcc2/gcc-2-build/gcc'
make: *** [bootstrap] Error 2

答案1

幸运的是,这是一个老问题了。我也遇到过这个问题,后来通过 Google 查找解决了。

在文件 arm.c (/gcc/config/arm) 中的第 530 行,根据上面的错误消息,按如下方式更正该行:

  arm_prgmode = TARGET_APCS_32 ? PROG_MODE_PROG32 : PROG_MODE_PROG26;

我不知道这个愚蠢的错误是如何渗入到代码中的,以及如何逃避检测。但唉,它就在那里。

编辑:

第二个错误不太具体,可能由多种因素造成。例如,你的 PATH 变量是否为空?

  echo $PATH

如果它回应类似

  /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

那么你就没问题了,否则

  export PATH= /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

将解决问题。

或者您可能需要安装/重新安装libc6-dev图书馆。在这种情况下,

  sudo apt-get purge libc6-dev
  sudo apt-get install libc6-dev

或者,您可以尝试使用(我发现这非常方便)预先构建的工具链,可从这里获得:https://github.com/raspberrypi/tools。即使您知道自己在做什么,从看似无穷无尽的编译错误列表中尝试找出所有缺失的部分也会很累人。

相关内容