ubuntu18.04编译Openwrt出现的问题解决


出现的问题多数是因为使用了新的编译器去编译老旧版本的openwrt,而出现的不兼容现象。
首先安装:
$sudo apt-get install aptitude

问题1:Build dependency: Please install Git (git-core) >= 1.6.5

原因一
缺少git
解决方法
安装git

$ sudo apt-get install git

注:如果已经安装git但是仍然收到该错误提示,请参考原因二,如果没有请忽略原因二。
原因二
这是openwrt一个脚本的问题,用一个古老的命令来判断git的版本。
由于对git版本的检测方式有缺陷导致,OpenWRT已经在
2016-03-05 21:07提交(4c80909fa141fe2921c62bd17b2b04153031df18)中修复该问题
解决方法
请参考https://github.com/openwrt/openwrt/commit/4c80909fa141fe2921c62bd17b2b04153031df18
修改文件 include/prereq-build.mk 中git版本的判断命令。
我这里的判断命令依然是 git clone 2>&1 | grep – –recursive)),
将其修改为 git –exec-path | xargs -I % – grep -q – –recursive %/git-submodule))
补丁文件如下:

diff --git a/include/prereq-build.mk b/include/prereq-build.mk
index 211201a..9067404 100644
--- a/include/prereq-build.mk
+++ b/include/prereq-build.mk
@@ -145,7 +145,7 @@ $(eval $(call SetupHostCommand,svn,Please install the Subversion client, \
 	svn --version | grep Subversion))
 
 $(eval $(call SetupHostCommand,git,Please install Git (git-core) >= 1.6.5, \
-	git clone 2>&1 | grep -- --recursive))
+	git --exec-path | xargs -I % -- grep -q -- --recursive %/git-submodule))
 
 $(eval $(call SetupHostCommand,file,Please install the 'file' package, \
 	file --version 2>&1 | grep file))

在这里插入图片描述

问题2:gdate.c:2497:7: error: format not a string literal, format string not checked [-Werror=format-nonliteral]

  tmplen = strftime (tmpbuf, tmpbufsize, locale_format, &tm);
  ^~~~~~

参考解决:https://github.com/widora/openwrt_widora/issues/12

diff --git a/glib/glib/gdate.c b/glib/glib/gdate.c
index 1978cf7..9be9b97 100644
--- a/glib/glib/gdate.c
+++ b/glib/glib/gdate.c
#第一处:2439行修改
@@ -2439,6 +2439,10 @@ win32_strftime_helper (const GDate     *d,
  *
  * Returns: number of characters written to the buffer, or 0 the buffer was too small
  */
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
 gsize     
 g_date_strftime (gchar       *s, 
                  gsize        slen, 
#第二处:2549行修改
@@ -2549,3 +2553,5 @@ g_date_strftime (gchar       *s,
   return retval;
 #endif
 }
+
+#pragma GCC diagnostic pop

修改两处文件:
./build_dir/host/pkg-config-0.28/glib/glib/gdate.c
./build_dir/host/glib-2.41.1/glib/gdate.c
PS:我只搜索到一个,所以就修改一个
在这里插入图片描述
在这里插入图片描述

问题3:Unescaped left brace in regex is illegal here in regex; marked by <-- HERE in m/${ <-- HERE ([^ \t=:+{}]+)}/ at ./bin/automake.tmp line 3938.

还有人报:Unescaped left brace in regex is illegal here in regex; marked by <-- HERE in m/${ <-- HERE ([^ \t=:+{}]+)}/ at /home/li/OS/IBSS/IBSS-openwrt.git/staging_dir/host/bin/automake line 4160.

问题原因:
是staging_dir/host/bin/automake的4160行报错
因为新版的perl不再支持左大括号的使用
解决:
对于:automake.tmp line 3938报错
补丁如下:内容主要修改automake.in文件
其他文件报错直接修改其路径上的文件即可!
参考连接:https://git.openwrt.org/?p=openwrt/openwrt.git;a=commitdiff;h=92c80f38cff3c20388f9ac13d5196f2745aeaf77;hp=079d57b0f290a79c9dbc013b6e9c83cebf8a2f99

+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;
+ }
+ 
+-- 
+2.13.1
+

在这里插入图片描述
在这里插入图片描述

问题4:[ERROR] cfns.gperf:101:1: error: ‘const char* libc_name_p(const char*, unsigned int)’ redeclared inline with ‘gnu_inline’ attribute

原因:
是一个inline内联的问题
解决方法:

//cfns.h 第55~56行中间插入
#ifdef __GNUC_STDC_INLINE__
__attribute__ ((__gnu_inline__))
#endif
//cfns.gperf 第24~25行中间插入
#ifdef __GNUC_STDC_INLINE__
__attribute__ ((__gnu_inline__))
#endif

此文件可在openwrt目录下直接搜索
cfns.h
在这里插入图片描述
最后贴上我找到此类问题参考解决方法的地址:
https://www.jianshu.com/p/976753126ca4
https://me.csdn.net/rainforest_c
http://blog.sina.com.cn/s/blog_bf7859030102x03k.html
https://bbs.archlinux.org/viewtopic.php?pid=1732548
https://blog.csdn.net/Javin_L/article/details/96015816

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

aron566

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值