title: buildroot构建根文件系统报错(set FORCE_UNSAFE_CONFIGURE=1)
author: cbus
categories:
- 小知识
tags: - 小知识
abbrlink: 53691
date: 2025-04-20 08:03:00
错误1 set FORCE_UNSAFE_CONFIGURE=1
在使用buildroot构建根文件系统时,一切按照文档的配置,但是在make的时候出现:
checking whether mknod can create fifo without root privileges... configure: error: in `/home/xxx/buildroot-2025.02/output/build/host-tar-1.35': configure: error: you should not run configure as root (set FORCE_UNSAFE_CONFIGURE=1 in environment to bypass this check) See `config.log' for more details package/pkg-generic.mk:253: recipe for target '/home/xxx/buildroot-2025.02/output/build/host-tar-1.35/.stamp_configured' failed make: *** [/home/xxx/buildroot-2025.02/output/build/host-tar-1.35/.stamp_configured] Error 1
错误2 expected 4.1.x, got 4.0.x
解决错误1之后,出现下面问题:
Incorrect selection of kernel headers: expected 4.1.x, got 4.0.x package/pkg-generic.mk:253: recipe for target '/home/xxxbuildroot-2025.02/output/build/toolchain-external-custom/.stamp_configured' failed make: *** [/home/xxx/buildroot-2025.02/output/build/toolchain-external-custom/.stamp_configured] Error 1
错误3 toolchain-external-custom/.stamp_configured failed
解决问题2后,编译过程出现以下问题:
Fortran support is not selected but is available in external toolchain package/pkg-generic.mk:253: recipe for target '/home/xxx/buildroot-2025.02/output/build/toolchain-external-custom/.stamp_configured' failed make: *** [/home/xxx/buildroot-2025.02/output/build/toolchain-external-custom/.stamp_configured] Error 1
OpenMP support is not selected but is available in external toolchain package/pkg-generic.mk:253: recipe for target '/home/zwl/linux/IMX6ULL/buildroot-2025.02/output/build/toolchain-external-custom/.stamp_configured' failed make: *** [/home/zwl/linux/IMX6ULL/buildroot-2025.02/output/build/toolchain-external-custom/.stamp_configured] Error 1
错误4 fatal error: sys/random.h: No such file or directory
解决以上问题后,又又又出现下面问题:
ubi-utils/ubihealthd.c:15:24: fatal error: sys/random.h: No such file or directory compilation terminated. Makefile:3020: recipe for target 'ubi-utils/ubihealthd.o' failed make[1]: *** [ubi-utils/ubihealthd.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make[1]: Leaving directory '/home/zwl/linux/IMX6ULL/buildroot-2025.02/output/build/host-mtd-2.2.1' package/pkg-generic.mk:270: recipe for target '/home/zwl/linux/IMX6ULL/buildroot-2025.02/output/build/host-mtd-2.2.1/.stamp_built' failed make: *** [/home/zwl/linux/IMX6ULL/buildroot-2025.02/output/build/host-mtd-2.2.1/.stamp_built] Error 2
ERROR: No hash found for busybox-1.29.3.tar.bz2 package/pkg-generic.mk:175: recipe for target '/home/zwl/linux/IMX6ULL/buildroot-2025.02/output/build/busybox-1.29.3/.stamp_downloaded' failed make: *** [/home/zwl/linux/IMX6ULL/buildroot-2025.02/output/build/busybox-1.29.3/.stamp_downloaded] Error 1
解决方法
可以看到,报错里面让我们
set FORCE_UNSAFE_CONFIGURE=1 in environment to bypass this check
。首先切换管理员用户
sudo su root
然后输入
export FORCE_UNSAFE_CONFIGURE=1
最后重新构建。
make
对于问题2
expected 4.1.x, got 4.0.x,意思是我们在配置buildroot的Toolchain时,选择的内核头为4.1.x,而交叉编译器里的内核头为4.0.x。我们打开交叉编译器的version.h文件
sudo vim /usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/include/linux/version.h
可以看到,LINUX_VERSION_CODE 262144,此值为10进制,转换为16进制为40000,对应的linux内核版本为4.0.x
我们将buildroot的Toolchain里面的
External toolchain kernel headers series
改为4.0.x,然后最好清理一下make clean
然后重新编译:
make
对于问题三,很明显,提示也给出了原因
进入配置界面在Toolchain交叉编译工具下输入y使能Fortran和OpenMP。
针对问题四,较老版本的Linux 是没有 sys/random.h 文件的,所以我们需要修改下载的busybox版本
进入busybox目录下:
/home/xxx/buildroot-2025.02/package/busybox
修改BUSYBOX_VERSION 为1.29.3.然后终端输入
make busybox-dirclean make
编译后,出现缺少Hash,添加Hash后,又会出现 Buildroot 正在尝试对
busybox-1.33.2
的源码打补丁时,找不到要打补丁的文件,所以补丁失败,最终构建失败。改到这博主又去把这些补丁删除,不让Buildroot打补丁,但是后续编译就会出错。
所以只能删掉现在的buildroot,换成低版本。换成低版本后,没有报错,直接可以编译成功,所以按照手册来才是最优解,不然折腾太磨人了。