解决 OpenWrt 编译过程中 toolchain/binutils 构建失败的问题
在尝试编译 OpenWrt 固件时,可能会遇到 toolchain/binutils 模块构建失败的情况。本文将详细分析该问题并提供解决方案。
问题描述
最近更新的 OpenWrt 版本中,toolchain/binutils 模块出现了构建错误。具体的错误信息如下:
make[3] -C toolchain/binutils compile ERROR: toolchain/binutils failed to build. make -r world: build failed. Please re-run make with -j1 V=s or V=sc for a higher verbosity level to see what's going on make: *** [/workdir/openwrt/include/toplevel.mk:231: world] Error 1 WARNING: Makefile 'package/feeds/packages/prometheus-node-exporter-lua/Makefile' has a dependency on 'bmx6', which does not exist WARNING: Makefile 'package/feeds/packages/prometheus-node-exporter-lua/Makefile' has a dependency on 'bmx6-json', which does not exist make[2]: Entering directory '/workdir/openwrt/scripts/config' make[2]: 'conf' is up to date. make[2]: Leaving directory '/workdir/openwrt/scripts/config' make[1]: Entering directory '/workdir/openwrt' make[2]: Entering directory '/workdir/openwrt' mkdir -p /workdir/openwrt/staging_dir/target-mipsel_24kc_musl cd /workdir/openwrt/staging_dir/target-mipsel_24kc_musl mkdir -p bin lib stamp usr/include usr/lib mkdir -p /workdir/openwrt/build_dir/target-mipsel_24kc_musl/stamp touch /workdir/openwrt/staging_dir/target-mipsel_24kc_musl/.prepared make[3]: Entering directory '/workdir/openwrt/toolchain/gdb' make[3]: Nothing to be done for 'compile'. make[3]: Leaving directory '/workdir/openwrt/toolchain/gdb' time: toolchain/gdb/compile#0.00#0.00#0.01 make[3]: Entering directory '/workdir/openwrt/toolchain/binutils' mkdir -p /workdir/openwrt/dl SHELL= flock /workdir/openwrt/tmp/.binutils-2.42.tar.xz.flock -c ' /workdir/openwrt/scripts/download.pl "/workdir/openwrt/dl" "binutils-2.42.tar.xz" "x" "" "@GNU/binutils/" ' Cannot find appropriate hash command, ensure the provided hash is either a MD5 or SHA256 checksum. make[3]: *** [Makefile:112: /workdir/openwrt/dl/binutils-2.42.tar.xz] Error 255 make[3]: Leaving directory '/workdir/openwrt/toolchain/binutils' time: toolchain/binutils/compile#0.02#0.00#0.03 ERROR: toolchain/binutils failed to build. make[2]: *** [toolchain/Makefile:97: toolchain/binutils/compile] Error 1 make[2]: Leaving directory '/workdir/openwrt' make[1]: *** [toolchain/Makefile:93: /workdir/openwrt/staging_dir/toolchain-mipsel_24kc_gcc-8.4.0_musl/stamp/.toolchain_compile] Error 2 make[1]: Leaving directory '/workdir/openwrt' make: *** [/workdir/openwrt/include/toplevel.mk:231: world] Error 2 Error: Process completed with exit code 2.
此外,还提示了无法找到适当的哈希命令,导致下载 binutils-2.42.tar.xz 文件失败:
Cannot find appropriate hash command, ensure the provided hash is either a MD5 or SHA256 checksum. make[3]: *** [Makefile:112: /workdir/openwrt/dl/binutils-2.42.tar.xz] Error 255
解决方法
为了解决这个问题,我们需要手动添加 PKG_HASH 变量到 toolchain/binutils/Makefile 文件中。具体步骤如下:
1. 打开 toolchain/binutils/Makefile 文件。
2. 在文件中找到 ifeq ($(PKG_VERSION),2.42) 这一行。
3. 在其下方添加以下代码:
PKG_HASH:=f6e4d41fd5fc778b06b7891457b3620da5ecea1006c6a4a41ae998109f85a800
完整的修改内容如下:
ifeq ($(PKG_VERSION),2.42) PKG_HASH:=f6e4d41fd5fc778b06b7891457b3620da5ecea1006c6a4a41ae998109f85a800 endif
保存并关闭文件后,重新运行编译命令:
make -j1 V=s
如果一切顺利,编译过程应该能够继续进行,不再出现 toolchain/binutils 构建失败的错误。
总结
通过手动添加 PKG_HASH 变量,解决了 OpenWrt 编译过程中 toolchain/binutils 模块构建失败的问题。
此方法简单有效,适用于临时解决编译问题。
点击链接加入群聊三群:751529538
点击链接加入群聊二群:376877156
点击链接加入群聊【路由器交流群:622891808已满】
本站附件分享,如果附件失效,可以去找找看
饿了么红包
于2024-11-15发布