busybox 交叉编译

news/2024/7/7 15:54:22 标签: compiler, function, path, library, each, build

1, 下载busybox,http://www.busybox.net/  


2, 下载arm-linux  交叉编译工具链arm-linux-gcc-3.4.5


3,进入busybox文件夹,makemenuconfig


Busybox Settings  ---> 

              Build Options  --->

                     [*] BuildBusyBox as a static binary (no shared libs)

                     [ ] ForceNOMMU build

                     [ ] Buildwith Large File Support (for accessing files > 2 GB)

                     (arm-softfloat-linux-gnu-)Cross Compiler prefix

                     ()  Additional CFLAGS

选中 “Cross Compiler prefix” ,回车,然后输入交叉编译工具链地址, 可以使用export PATH=$PATH:$(your cross compiler path)


注意: 这里选择的是静态编译busybox  ,  所以自己的程序交叉编译的时候也需要静态编译。否则无法运行。


动态编译操作:

1).BusyBox-1.10.1的配置中将如下选项勾上:

Busybox settings->

Build Options->

Build shared bosybox->

将如下两项去掉勾(不去掉编译通不过,具体愿因还未研究):

Produce a binary for each applet,linked against libbusybox.

Produce a additional busybox binary linked against libbusybox.


2).在建立文件系统时将交叉编译器的lib库全部复制到文件系统的ib库中,一般可以运行起来,如果还差其它动态库,则找到后放在文件系统的lib库下即可.如我的4.0版本的交叉编译器lib库为../arm-9tdmi-linux-gnu/arm-9tdmi-linux-gnu/lib下面,复制到文件系统的lib目录中,并在etc目录下建立一个ld.so.conf配置文件,将动态库的路径加入其中,usr/local/lib,保存.然事在PC上对文件系统根目录运行配置命令:如根目录为netfs,则如下:

ldconfig –r netfs

之后在etc下生成一个ld.so.cache的文件,这样启动后即可加载动态编译的文件系统了,自己的编译的程序也不用静态编译了.




4, make


出错: #1  

       miscutils/ionice.c:16:error: `SYS_ioprio_set' undeclared (first use in this function)

       miscutils/ionice.c:16:error: (Each undeclared identifier is reported only once

       miscutils/ionice.c:16:error: for each function it appears in.)

解决:

miscutils/ionice.c添加如下内容:

       #define SYS_ioprio_set 289

       #define SYS_ioprio_get 290

       (这个宏可以在主机的/usr/include下查到)

       重新编译:


出错: #2

miscutils/nandwrite.c:49:26: mtd/mtd-user.h: No such file or directory

解决:

cp /usr/include/mtd/  ./include/mtd/  -a


出错:  #3

networking/interface.c:818: error: `ARPHRD_INFINIBAND’ undeclared here(not in a function)

解决:

修改networking/interface.c
vim networking/interface.c
添加define ARPHRD_INFINIBAND 32 /* InfiniBand */

出错: #4

错误4:
util-linux/acpid.c: In function `acpid_main’:
util-linux/acpid.c:146: error: `EV_SW’ undeclared (first use in thisfunction)
util-linux/acpid.c:146: error: (Each undeclared identifier is reportedonly once
util-linux/acpid.c:146: error: for each function it appears in.)
util-linux/acpid.c:147: error: `SW_LID’ undeclared (first use in thisfunction)


解决:
cp /opt/linuxcore/linux-2.6.33.3/include/linux/ ./include/ -a



5,make install

生成   _install 文件夹


6, 配置文件系统


mkdir dev etc lib mnt proc var tmp sys root

建立初始化启动所需文件

Ø  创建inittab文件

       进入_install/etc目录,建立inittab文件,文件内容:

       #this is run first except when booting insingle-user mode.

       :: sysinit:/etc/init.d/rcS

          # /bin/sh invocations on selected ttys

       # Start an "askfirst" shell on theconsole (whatever that may be)

          ::askfirst:-/bin/sh

          # Stuff to do when restarting the init process

          ::restart:/sbin/init

          # Stuff to do before rebooting

          ::ctrlaltdel:/sbin/reboot

Ø  创建fstab文件

       进入_install/etc下面,创建fstab文件,添加如下内容

       #device       mount-point     type   options              dump             fsckorder

       proc           /proc              proc     defaults           0           0

       tmpfs        /tmp                  tmpfs   defaults              0                 0

       sysfs         /sys                    sysfs    defaults        0                   0

       tmpfs          /dev                   tmpfs   defaults              0                 0


Ø  创建init.d/rcS

进入_install/etc下创建init.d/rcS文件,添加如下内容

              #!/bin/sh

          # This is the first script called by init process

          /bin/mount –a

Ø  创建profile文件

进入_install/etc下创建profile文件,添加如下内容:

#!/bin/sh

export HOSTNAME=mylinux

export USER=root

export HOME=root

#export PS1="\[\u@\h \W\]\$ "

cd root

export PS1="[$USER@$HOSTNAME \W]\# "

PATH=/bin:/sbin:/usr/bin:/usr/sbin

LD_LIBRARY_PATH=/lib:/usr/lib:$LD_LIBRARY_PATH

export PATH LD_LIBRARY_PATH

Ø  dev下创建终端设备节点console

进入_install/dev创建设备节点console

mknod console        c    5   1

Ø  建立嵌入式系统库

cp gcc-3.4.5-glibc-2.3.6/arm-linux/lib_install/lib/ -a

cd_install/lib

删除所又无用的目录和静态库 (所有的目录和.a文件)

然后剥除库文件中的调试段等信息,从而减小库的体积。运行:

arm-softfloat-linux-gnu-strip *.so


http://www.niftyadmin.cn/n/1116354.html

相关文章

[译] Kotlin 、协程、结构化并发

原文链接:Structured concurrency原文作者:Roman Elizarov今天(译者注:18年9月12日) 是 kotlinx.coroutines 0.26.0 版本的发布日,同时会对 Kotlin 协程的「结构化并发」做一些介绍。它不仅仅是一个功能改变——它标志着编程风格的…

Java开发岗位面试题归类---怎么好好的准备面试,也算是发展学习方向

转载:http://blog.csdn.net/qq_27093465/article/details/52181860 一、Java基础 1. String类为什么是final的。 自己找的参考答案 2. HashMap的源码,实现原理,底层结构。 答案一:简单好理解,但是版本有点老的hashmap实…

BZOJ 3589 动态树(子树操作,链查询)

题目链接:http://www.lydsy.com:808/JudgeOnline/problem.php?id3589 题意:给出一棵有根树,两种操作:(1)以u为根的子树所有节点权值加上一个数字;(2)给出若干个链&#…

Consuming a RESTful Web Service

本篇文章将介绍使用Spring来建立RESTful的Web Service。 我们通过一个例子来说明这篇文章:这个例子将会使用Spring的RestTemplate来从Facebook的提供的API中获取一些信息。然后对这些信息进行一些处理。Facebook的API为: http://graph.facebook.com/gopi…

RZ,SZ命令的安装配置

RZ,SZ命令的安装配置参考:http://hi.baidu.com/dkf198314/blog/item/d76e9e3b2bb9a6f83b87cee1.htmlhttp://bbs.phphubei.com/thread-5466-1-1.htmlhttp://hi.baidu.com/shineastdh/blog/ite ... 3ab6d.html1,搭建环境:主机&#…

转载 --mysql函数大全

控制流函数 IFNULL(expr1,expr2) 如果expr1不是NULL,IFNULL()返回expr1,否则它返回expr2。IFNULL()返回一个数字或字符串值,取决于它被使用的上下文环境。 mysql> select IFNULL(1,0);-> 1 mysql> select IFNULL(0,10);-> 0 my…

springboot + mybatis +easyUI整合案例

概述 springboot推荐使用的是JPA,但是因为JPA比较复杂,如果业务场景复杂,例如企业应用中的统计等需求,使用JPA不如mybatis理想,原始sql调优会比较简单方便,所以我们的项目中还是使用的mysql,并未…

编译busybox,动态链接与静态链接的选择

编译busybox,动态链接与静态链接的选择 进入解压后的Busybox-1.10.1目录,运行make menuconfig或make gconfig进行配置。 在进行配置时有几项需要注意: Build Options-> Build BusyBox as a static binary (no shared libs)…