|
【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
|