busybox在make編譯過程中出錯
博主在busybox安裝時,在make編譯時出了兩個錯:'MTD_FILE_MODE_RAW' undeclared和'BLKSECDISCARD' undeclared ,在經過上網百度時,發現幾乎所有的部落格都是千篇一律,但是實際試了一下,發現並沒有成功。在經過根據自己的猜想和實驗之後,自己想出了一種解決方法,貼出來交流一下。
(前四步為busybox安裝過程,第5步為上述問題的解決方法)
1.到官網下載busybox,並且在ubuntu中解壓 busybox官網連結
2.在Makefile中修改ARCH = arm和
CROSS_COMPILE = /你自己的交叉編譯工具鏈的路徑/bin/arm-none-linux-gnueabi-
3.make menuconfig進行配置(這一步的前題是你的Ubuntu系統裡安裝有ncurses庫),配置項按下面的進行修改,下面沒有提到的配置項就按預設的來:
Busybox Settings--->
Build Options--->
[*]Build BusyBox as a static binary(no shared libs)
Busybox Library Tuning--->
[*]vi-style line editing commands
[*]Fancy shell prompts
Coreutils--->
[ ]sync
Linux Module Utilities--->
[ ]Simplified modutils
[*]insmod
[*]rmmod
[*]lsmod
[*]modprobe
[*]depmod
Linux System Utilities--->
[*]mdev
[*]Support /etc/mdev.conf
[*]Support subdirs/symlinks
[*]Support regular expressions substitutions when renaming dev
[*]Support command execution at device addition/removal
[*]Support loading of firmwares
[ ]nsenter
4.make進行編譯,之後make install進行安裝,make menuconfig配置以下項可以修改安裝的目錄
Busybox Settings--->
BusyBox installation prefix
5.注意:
make編譯中出現如下錯誤時:
miscutils/nandwrite.c: In function 'nandwrite_main':
miscutils/nandwrite.c:151: error: 'MTD_FILE_MODE_RAW' undeclared (first use in this function)
miscutils/nandwrite.c:151: error: (Each undeclared identifier is reported only once
miscutils/nandwrite.c:151: error: for each function it appears in.)
scripts/Makefile.build:197: recipe for target 'miscutils/nandwrite.o' failed
make[1]: *** [miscutils/nandwrite.o] Error 1
Makefile:742: recipe for target 'miscutils' failed
make: *** [miscutils] Error 2
可以在/交叉編譯工具鏈路徑//arm-none-linux-gnueabi/libc/usr/include/mtd/mtd-abi.h檔案中末尾的
enum mtd_file_modes {
MTD_MODE_NORMAL = MTD_OTP_OFF,
MTD_MODE_OTP_FACTORY = MTD_OTP_FACTORY,
MTD_MODE_OTP_USER = MTD_OTP_USER,
MTD_MODE_RAW,
};
修改為
enum mtd_file_modes {
MTD_MODE_NORMAL = MTD_OTP_OFF,
MTD_MODE_OTP_FACTORY = MTD_OTP_FACTORY,
MTD_MODE_OTP_USER = MTD_OTP_USER,
MTD_MODE_RAW,
MTD_FILE_MODE_RAW,
};
make出現如下錯誤時:
util-linux/blkdiscard.c: In function 'blkdiscard_main':
util-linux/blkdiscard.c:72: error: 'BLKSECDISCARD' undeclared (first use in this function)
util-linux/blkdiscard.c:72: error: (Each undeclared identifier is reported only once
util-linux/blkdiscard.c:72: error: for each function it appears in.)
scripts/Makefile.build:197: recipe for target 'util-linux/blkdiscard.o' failed
make[1]: *** [util-linux/blkdiscard.o] Error 1
Makefile:742: recipe for target 'util-linux' failed
make: *** [util-linux] Error 2
在/交叉編譯工具鏈路徑/arm-none-linux-gnueabi/libc/usr/include/linux/fs.h檔案中新增一句 #define BLKSECDISCARD _IO(0x12,119)
修改完這兩項之後,再去make編譯就不會出錯了,接著就可以正常安裝了。
如果修改完這兩個檔案仍有錯誤,可以檢視一下自己make menuconfig配置時是否與我上邊的第3步的配置一樣。