编译 toybox (enable smack)

来源:互联网 发布:ipad手绘软件 编辑:程序博客网 时间:2024/05/16 04:41

在编译 toybox的时候,选中了 smack选项,然后,编译的时候,报错:

In file included from ./toys.h:71:0,                 from lib/xwrap.c:10:./lib/lsm.h:23:23: fatal error: sys/smack.h: No such file or directorycompilation terminated.In file included from ./toys.h:71:0,                 from lib/llist.c:6:./lib/lsm.h:23:23: fatal error: sys/smack.h: No such file or directory

原因是缺少 smack库。

可以从下面的页面下载到:

http://schaufler-ca.com/presentations_and_documents

http://github.com/smack-team

解压后,在 libsmack下有个sys目录。这个就是要包含的头文件目录。

编译 smack代码,会出来一个库。

然后,回到 toybox, 通过 CFLAGS指定头文件位置,执行  make:

$ CFLAGS="-I$HOME/code/qemu/smack-master/libsmack" make 
但是仍然报头文件找不到的问题。。

解决方法是,把下面的几行

254 if [ generated/config2help -ot scripts/config2help.c ]255 then256   do_loudly $HOSTCC scripts/config2help.c -I . lib/xwrap.c lib/llist.c \257     lib/lib.c lib/portability.c -o generated/config2help || exit 
改为:

254 if [ generated/config2help -ot scripts/config2help.c ]255 then256   do_loudly $HOSTCC $CFLAGS scripts/config2help.c -I . lib/xwrap.c lib/llist.c \257     lib/lib.c lib/portability.c -o generated/config2help || exit 

即在256行加上 CFLAGS。

最后加上LDFLAGS:

$ CFLAGS="-I$HOME/code/qemu/smack-master/libsmack" LDFLAGS="-L$HOME/code/qemu/smack-master/libsmack/.libs -lsmack" make scripts/make.shGenerate headers from toys/*/*.c...Make generated/config.h from .config.Compile toybox.....

也可以使用 C_INCLUDE_PATH代替 CFLAGS.

最后使用一个脚本编译。内容如下:

cd toybox-0.7.3CFLAGS="-I$HOME/code/qemu/smack-master/libsmack"CFLAGS="$CFLAGS -I$HOME/code/qemu/openssl-1.1.0e/include"LDFLAGS="-L$HOME/code/qemu/smack-master/libsmack/.libs -lsmack"LDFLAGS="$LDFLAGS -L$HOME/code/qemu/openssl-1.1.0e -lcrypto -lssl"ARCH=armCROSS_COMPILE=arm-linux-gnueabi-export CFLAGS LDFLAGS ARCH CROSS_COMPILEmakerm -rf $HOME/mytoyboxPREFIX=$HOME/mytoybox make install


0 0