谷动谷力

 找回密码
 立即注册
查看: 594|回复: 0
打印 上一主题 下一主题
收起左侧

【openwrt】ubuntu20环境下编译openwrt15(Chaos Calmer)因GCC版本太...

[复制链接]
跳转到指定楼层
楼主
发表于 2023-6-23 19:36:34 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
【openwrt】ubuntu20环境下编译openwrt15(Chaos Calmer)因GCC版本太高 而编译不通过

【现象】
编译出错提示:
In file included from include/linux/compiler.h:54,
from /home/fan/openwrt_CC_mt76xx_zhuotk_source/build_dir/host/u-boot-2014.10/arch/sandbox/include/asm/bitops.h:20,
from include/linux/bitops.h:110,
from /home/fan/openwrt_CC_mt76xx_zhuotk_source/build_dir/host/u-boot-2014.10/include/common.h:20:
include/linux/compiler-gcc.h:114:1: fatal error: linux/compiler-gcc9.h: No such file or directory
114 | #include gcc_header(GNUC)
| ^~~~
compilation terminated.
make[6]: *** [/home/fan/openwrt_CC_mt76xx_zhuotk_source/build_dir/host/u-boot-2014.10/scripts/Makefile.autoconf:64: include/autoconf.mk] Error 1
make[5]: *** [/home/fan/openwrt_CC_mt76xx_zhuotk_source/build_dir/host/u-boot-2014.10/Makefile:464: silentoldconfig] Error 1
make[4]: *** No rule to make target 'include/config/auto.conf', needed by 'include/config/uboot.release'.  Stop.
make[4]: Leaving directory '/home/fan/openwrt_CC_mt76xx_zhuotk_source/build_dir/host/u-boot-2014.10'
make[3]: *** [Makefile:48: /home/fan/openwrt_CC_mt76xx_zhuotk_source/build_dir/host/u-boot-2014.10/.built] Error 2

【原因】
ubuntu20默认的gcc9版本太高了,怕有其它问题,所以首先我是将gcc进行降版本,并切换为gcc-4.8
Ubuntu20.04终端安装、切换低版本gcc/g++

【解决方法】
增加源
sudo vim /etc/apt/sources.list
添加
deb http://dk.archive.ubuntu.com/ubuntu/ xenial main
deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe

更新源
sudo apt-get update
安装gcc5,g++5
sudo apt-get install g++-5 gcc-5
安装gcc4,g++4
sudo apt-get install g++-4.8 gcc-4.8
设置优先级
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/g++-4.8 40
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 50
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/g++-5 50
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/g++-9 90
选择gcc版本
sudo update-alternatives --config gcc
There are 6 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path              Priority   Status
------------------------------------------------------------
  0            /usr/bin/g++-9     90        auto mode
  1            /usr/bin/g++-4.8   40        manual mode
  2            /usr/bin/g++-5     50        manual mode
  3            /usr/bin/g++-9     90        manual mode
  4            /usr/bin/gcc-4.8   40        manual mode
* 5            /usr/bin/gcc-5     50        manual mode
  6            /usr/bin/gcc-9     90        manual mode

Press <enter> to keep the current choice, or type selection number: 5
我选择的是gcc-5  

实践证明:用此版本的gcc 是可以编译通过的。
+10

本帖被以下淘专辑推荐:

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|深圳市光明谷科技有限公司|光明谷商城|Sunshine Silicon Corpporation ( 粤ICP备14060730号|Sitemap

GMT+8, 2024-5-18 13:38 , Processed in 0.093535 second(s), 43 queries .

Powered by Discuz! X3.2 Licensed

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表