mtd-utils交叉编译

时间:2022-12-05 00:21:36

在网上参考了很多人的文章,开始就是编译不过去,提示/sys/acl.h无法找到!

最后终于解决,原因是路径的问题

 

1、源码

http://www.zlib.net/zlib-1.2.5.tar.gz

http://www.oberhumer.com/opensource/lzo/download/lzo-2.03.tar.gz

ftp://ftp.infradead.org/pub/mtd-utils/mtd-utils-1.4.1.tar.bz2

 

说明:zlib和lzo是编译mtd-utils所需库文件,需提前交叉编译完成,以供mtd-utils编译时调用

 

2、编译安装zlib:

root@:/home/# cd zlib-1.2.5

root@:/home/zlib-1.2.5# CC=arm-none-linux-gnueabi-gcc  ./configure --shared --prefix=/opt/armv6/codesourcery/arm-none-linux-gnueabi/

root@:/home/zlib-1.2.5# make

root@:/home/zlib-1.2.5# make install

 

其中-prefix指定zlib的安装路径,需要指定到交叉编译器所在路径!

 

 

3、编译安装lzo:

root@:/home/# cd lzo-2.03/

root@:/home/lzo-2.03# 编译安装lzo:

root@:/home/# cd lzo-2.03/

root@:/home/lzo-2.03# CC=arm-none-linux-gnueabi-gcc ./configure --host=arm-linux --prefix=/opt/armv6/codesourcery/arm-none-linux-gnueabi/

root@:/home/lzo-2.03# make

root@:/home/lzo-2.03# make install

 

 

4、编译mtd-utils

 

make CROSS=/opt/armv6/codesourcery/bin/arm-none-linux-gnueabi- WITHOUT_XATTR=1

 

 

指定WITHOUT_XATTR=1 是由于在编译 mkfs.jffs2使其不调用acl.h而是用zlib的库,否则会报错:

mkfs.jffs2.c:69:21: error: sys/acl.h: No such file or directory
mkfs.jffs2.c: In function ‘formalize_posix_acl’:
mkfs.jffs2.c:1118: error: ‘ACL_USER_OBJ’ undeclared (first use in this function)
mkfs.jffs2.c:1118: error: (Each undeclared identifier is reported only once
mkfs.jffs2.c:1118: error: for each function it appears in.)
mkfs.jffs2.c:1119: error: ‘ACL_GROUP_OBJ’ undeclared (first use in this function)
mkfs.jffs2.c:1120: error: ‘ACL_MASK’ undeclared (first use in this function)
mkfs.jffs2.c:1121: error: ‘ACL_OTHER’ undeclared (first use in this function)
mkfs.jffs2.c:1127: error: ‘ACL_USER’ undeclared (first use in this function)
mkfs.jffs2.c:1128: error: ‘ACL_GROUP’ undeclared (first use in this function)
make: *** [mkfs.jffs2.o] Error 1

 

有人写到出现此错误需要安装libacl-dev,个人觉得如果指定WITHOUT_XATTR=1,就不需要安装!