在编译OpenHarmony遇到third_party/libnl编译报错的修复办法
笔者是在WSL(Ubuntu 20.04)环境下编译OpenHarmony遇到的错误,究其原因是鸿蒙在将安装软件的步骤添加到了编译阶段,在编译阶段一般是非root用户,而安装软件需要root权限(或许要输入密码),因此报错。解决办法就是将编译阶段的安装步骤跳过,手动提前安装即可,详细步骤如下。
1、手动安装依赖(执行命令可能要输入密码):
sudo apt-get update
sudo apt-get install autoconf automake libtool -y
2、删除或者注释掉third_party/libnl/install.sh中的两条apt-get命令(大约在17、18行):
# apt-get update
# apt-get install autoconf automake libtool -y
3、在third_party/libnl/libnl/configure.ac中加入(大约在12行之后):
m4_pattern_allow([AC_MSG_WARN])
m4_pattern_allow([AC_MSG_ERROR])
m4_pattern_allow([PKG_CHECK_MODULES])
4、在third_party/libnl/libnl/configure.ac中注释或删除掉如下几行:
下面几行删掉或注释掉:
PKG_CHECK_MODULES([CHECK], [check >= 0.9.0],
[has_check="yes"],
[AC_MSG_WARN([*** Disabling building of unit tests])
has_check="no"])
AM_CONDITIONAL(WITH_CHECK, [test "$has_check" = 'yes'])
随后加入如下代码:
# 硬编码设置变量值以跳过检查
has_check="no"
AM_CONDITIONAL(WITH_CHECK, [test "$has_check" = 'yes'])
5、在third_party/libnl/install.sh中16行加入,前提是需要将修改好后的configure.ac拷贝出来到install.sh同级目录:
cp -arf configure.ac $1/libnl/