最近,OpenWRT开发主战场,从ubuntu16.04 LTS 虚拟机环境迁移到了ubuntu18.04LTS,水土不服,各种不适。不多说,折腾!!!
1. 初检git出错 依赖提示 Please install Git (git-core) >= 1.6.5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ➜ openwrt git:(master) ✗ make menuconfig Checking 'working-make' ... ok. . . . Checking 'svn' ... ok. Checking 'git' ... failed. Checking 'file' ... ok. Checking 'openssl' ... ok. Checking 'ldconfig-stub' ... ok. Build dependency: Please install Git (git-core) >= 1.6.5 /home/ubuntu/buildbot/compex/chaos_calmer/openwrt/include/prereq.mk:12: recipe for target 'prereq' failed Prerequisite check failed. Use FORCE=1 to override. /home/ubuntu/buildbot/compex/chaos_calmer/openwrt/include/toplevel.mk:140: recipe for target 'staging_dir/host/.prereq-build' failed make: *** [staging_dir/host/.prereq-build] Error 1
明明已经安装了git,却提示我们安装git,只是openwrt里面prereq-build.mk的一个bug,可以通过打patch的方法来修复它。
解决方案 进到xxx/chaos_calmer/include目录,就是toplevel.mk所在的目录。
1 2 wget https://gitlab.labs.nic.cz/turris/openwrt/uploads/0673001b14ab1d1769604ff0ce7d8781/git-version-check-fix.patch patch < git-version-check-fix.patch
回到openwrt根目录,再次检查依赖,发现没,没有问题了。
2. gdate.c错误 1 2 3 gdate.c: In function 'g_date_strftime' : tmplen = strftime (tmpbuf, tmpbufsize, locale_format, &tm); ^~~~~~
解决方案 单独改源码方式不好,下次重新编译有可能又要重新改, 所以新建个patch一劳永逸.
在tools/pkg-config/目录下创建目录patches并在patches目录中新建文件 001-glib-gdate-suppress-string-format-literal-warning.patch
内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 --- a/glib/glib/gdate.c +++ b/glib/glib/gdate.c @@ -2439,6 +2439,9 @@ win32_strftime_helper (const GDate *d, * * Returns: number of characters written to the buffer, or 0 the buffer was too small */ + + + gsize g_date_strftime (gchar *s, gsize slen, @@ -2549,3 +2552,5 @@ g_date_strftime (gchar *s, return retval; } + +
3. automake错误,与perl版本有关 1 2 3 4 5 6 7 8 9 10 11 Makefile:50: recipe for target '/home/ubuntu/buildbot/compex/chaos_calmer/openwrt/build_dir/host/automake-1.15/.configured' failed make[3]: *** [/home/ubuntu/buildbot/compex/chaos_calmer/openwrt/build_dir/host/automake-1.15/.configured] Error 255 make[3]: Leaving directory '/home/ubuntu/buildbot/compex/chaos_calmer/openwrt/tools/automake' tools/Makefile:122: recipe for target 'tools/automake/compile' failed make[2]: *** [tools/automake/compile] Error 2 make[2]: Leaving directory '/home/ubuntu/buildbot/compex/chaos_calmer/openwrt' tools/Makefile:121: recipe for target '/home/ubuntu/buildbot/compex/chaos_calmer/openwrt/staging_dir/target-mips_34kc_uClibc-0.9.33.2/stamp/.tools_install_yynyynynynyyyyyyyyyyyyyyyyyyynyyyyynnyyynyyynnnyy' failed make[1]: *** [/home/ubuntu/buildbot/compex/chaos_calmer/openwrt/staging_dir/target-mips_34kc_uClibc-0.9.33.2/stamp/.tools_install_yynyynynynyyyyyyyyyyyyyyyyyyynyyyyynnyyynyyynnnyy] Error 2 make[1]: Leaving directory '/home/ubuntu/buildbot/compex/chaos_calmer/openwrt' /home/ubuntu/buildbot/compex/chaos_calmer/openwrt/include/toplevel.mk:181: recipe for target 'world' failed make: *** [world] Error 2
原因 查看perl版本
1 2 perl -v This is perl 5 , version 26 , subversion 1 (v5.26.1 ) built for x86_64-linux-gnu-thread-multi
新版本perl对一些写法不支持,需要增加一个插件
解决办法 在 tools/automake/patchs/ 目录下创建新文件 210_automake_perl_5.26.1_ver.patch
内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 diff --git a/bin/automake.in b/bin/automake.in index a3a0aa318..2c8f31e14 100644 --- a/bin/automake.in +++ b/bin/automake.in @@ -3878,7 +3878,7 @@ sub substitute_ac_subst_variables_worker sub substitute_ac_subst_variables { my ($text ) = @_; - $text =~ s/\${([^ \t=:+{} ]+)}/substitute_ac_subst_variables_worker ($1 )/ge; + $text =~ s/\$[{]([^ \t=:+{}]+)}/substitute_ac_subst_variables_worker ($1 )/ge; return $text ; }
4. gcc版本问题 1 2 include/linux/compiler-gcc.h:114:1: fatal error: linux/compiler-gcc7.h: No such file or directory
原因 ubuntu18.04默认安装的gcc版本较高,为gcc7;
解决方案 参考https://github.com/openwrt/openwrt/blob/70b104f98c0657323b28fce140b73a94bf3eb756/tools/mkimage/patches/200-compiler-support.patch
给mkimage打个patch,
在 tools/mkimage/patches/ 目录下wget 200-compiler-support.patch
如下:
1 wget https://raw.githubusercontent.com/openwrt/openwrt/70b104f98c0657323b28fce140b73a94bf3eb756/tools/mkimage/patches/200-compiler-support.patch
5. 模块 mkimage(u-boot-2014.10) 出错 1 2 u-boot-2014.10/lib/rsa/rsa-sign.c:279:21: error: dereferencing pointer to incomplete type 'RSA {aka struct rsa_st}' if (BN_num_bits(key->e) > 64)
原因 OpenSSL版本是1.1x,OpenSSL 1.1.x对一些API做了改动,因此出现错误信息。
1 2 ➜ openssl version OpenSSL 1.1.1 11 Sep 2018
解决方法 参考https://github.com/openwrt/openwrt/commit/70b104f98c0657323b28fce140b73a94bf3eb756
在 tools/mkimage/patches/ 目录下wget 210-openssl-1.1.x-compat.patch
如下:
1 wget https://raw.githubusercontent.com/openwrt/openwrt/70b104f98c0657323b28fce140b73a94bf3eb756/tools/mkimage/patches/210-openssl-1.1.x-compat.patch
6. gcc4.8编译出错 到这一步,一些哥们干脆把系统gcc降级回到gcc4.8,解决问题。坚决不妥协,继续。。。
解决方案 添加条件编译宏定义
1 2 3 #ifdef __GNUC_STDC_INLINE__ __attribute__ ((__gnu_inline__)) #endif
到目录openwrt/build_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/gcc-linaro-4.8-2014.04/gcc/cp/下的cfns.gperf(25行)和cfns.h文件(50行)如下
1 2 3 4 5 6 7 8 9 10 11 #ifdef __GNUC__ __inline #endif static unsigned int hash (const char *, unsigned int); #ifdef __GNUC__ __inline #ifdef __GNUC_STDC_INLINE__ __attribute__ ((__gnu_inline__)) #endif #endif const char * libc_name_p (const char *, unsigned int);
7. 编译coccinelle-1.0.0-rc24c出错 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 /usr/bin/ld: /home/ubuntu/buildbot/ipq40xx_qca/staging_dir/host/lib/libpython2.7.a(bytes_methods.o): relocation R_X86_64_32S against symbol `_Py_ctype_table' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: error: ld returned 1 exit status Makefile:46: recipe for target ' dllpycaml_stubs.so' failed make[10]: *** [dllpycaml_stubs.so] Error 2 make[10]: Leaving directory ' /home/ubuntu/buildbot/ipq40xx_qca/build_dir/host/coccinelle-coccinelle-1.0.0-rc24/bundles/pycaml' Makefile:26: recipe for target ' all' failed make[9]: *** [all] Error 2 make[9]: Leaving directory ' /home/ubuntu/buildbot/ipq40xx_qca/build_dir/host/coccinelle-coccinelle-1.0.0-rc24/bundles/pycaml' Makefile:271: recipe for target ' /home/ubuntu/buildbot/ipq40xx_qca/build_dir/host/coccinelle-coccinelle-1.0.0-rc24/bundles/pycaml/.all' failed make[8]: *** [/home/ubuntu/buildbot/ipq40xx_qca/build_dir/host/coccinelle-coccinelle-1.0.0-rc24/bundles/pycaml/.all] Error 2 make[8]: Leaving directory ' /home/ubuntu/buildbot/ipq40xx_qca/build_dir/host/coccinelle-coccinelle-1.0.0-rc24' Makefile:265: recipe for target ' subdirs.all' failed make[7]: *** [subdirs.all] Error 1 make[7]: Leaving directory ' /home/ubuntu/buildbot/ipq40xx_qca/build_dir/host/coccinelle-coccinelle-1.0.0-rc24' Makefile:177: recipe for target ' byte' failed make[6]: *** [byte] Error 2 make[6]: Leaving directory ' /home/ubuntu/buildbot/ipq40xx_qca/build_dir/host/coccinelle-coccinelle-1.0.0-rc24' Makefile:157: recipe for target ' all-dev' failed make[5]: *** [all-dev] Error 2 make[5]: Leaving directory ' /home/ubuntu/buildbot/ipq40xx_qca/build_dir/host/coccinelle-coccinelle-1.0.0-rc24' Makefile:142: recipe for target ' all' failed make[4]: *** [all] Error 2 make[4]: Leaving directory ' /home/ubuntu/buildbot/ipq40xx_qca/build_dir/host/coccinelle-coccinelle-1.0.0-rc24' Makefile:21: recipe for target ' /home/ubuntu/buildbot/ipq40xx_qca/build_dir/host/coccinelle-coccinelle-1.0.0-rc24/.built' failed make[3]: *** [/home/ubuntu/buildbot/ipq40xx_qca/build_dir/host/coccinelle-coccinelle-1.0.0-rc24/.built] Error 2 make[3]: Leaving directory ' /home/ubuntu/buildbot/ipq40xx_qca/tools/coccinelle' tools/Makefile:124: recipe for target ' tools/coccinelle/compile' failed make[2]: *** [tools/coccinelle/compile] Error 2 make[2]: Leaving directory ' /home/ubuntu/buildbot/ipq40xx_qca' tools/Makefile:123: recipe for target ' /home/ubuntu/buildbot/ipq40xx_qca/staging_dir/target-arm_cortex-a7_uClibc-1.0.14_eabi/stamp/.tools_install_yynyynyynynyyyyyyyyynyyyyyyyyynyyyyynnyyyynnyynnnyy' failed make[1]: *** [/home/ubuntu/buildbot/ipq40xx_qca/staging_dir/target-arm_cortex-a7_uClibc-1.0.14_eabi/stamp/.tools_install_yynyynyynynyyyyyyyyynyyyyyyyyynyyyyynnyyyynnyynnnyy] Error 2 make[1]: Leaving directory ' /home/ubuntu/buildbot/ipq40xx_qca' /home/ubuntu/buildbot/ipq40xx_qca/include/toplevel.mk:186: recipe for target ' world' failed make: *** [world] Error 2
原因 coccinelle-coccinelle-1.0.0-rc21对应ocaml 4.02.3
1 2 ➜ tools ocaml -version The OCaml toplevel, version 4.05.0
系统ocaml的版本太高,将ocaml降到4.02.3,就可以解决。
解决方案 安装opam
1 2 3 add-apt-repository ppa:avsm/ppa apt update apt install opam
初始化,并安装 ocaml 4.02.3
1 2 3 4 5 6 7 8 9 opam init eval `opam env`opam switch create 4.02.3 eval `opam env`which ocamlocaml -version
Enjoy! 附 gcc多版本切换方法 Ubuntu18.04操作系统默认预装GCC 7.3版本,不过有时候在编译时是需要用不同gcc的版本,本文介绍怎样安装不同的gcc和g++,并设置根据不同的需要在不同版本之间转换。
1、可以通过如下命令查看当前安装的版本:
将ubuntu-toolchain-r/test PPA添加到您的系统
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
2、安装gcc-4.8和gcc-5.2:
1 2 3 sudo apt install gcc-4.8 gcc-4.8-multilib g++-4.8 g++-4.8-multilib sudo apt install gcc-5 gcc-5-multilib g++-5 g++-5-multilib
3、使用update-alternatives设置gcc和g++:
update-alternatives是ubuntu系统中专门维护系统命令链接符的工具,通过它可以很方便的设置系统默认使用哪个命令、哪个软件版本。
其中40 ,50 ,70是优先级数值可以自己设定,–slave能保证gcc和g++保持相同的版本。
1 2 3 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 50 --slave /usr/bin/g++ g++ /usr/bin/g++-5 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7
4、使用如下命令选择gcc的版本:
运行如下命令:
1 sudo update-alternatives --config gcc
可以看到当前gcc默认的版本是gcc-7,下面我们修改为gcc-4.8,直接选择编号即可。
5、验证是否修改成功,运行命令:
6、删除的方法
删除某个gcc版本的选项的话,可以使用命令:
1 sudo update-alternatives --remove gcc /usr/bin/*(*为gcc版本号,比如gcc-4.8)
再使用apt-remove
删除即可。