嵌入式linux-busybox 工具静态编译

      嵌入式linux因资源紧缺,所以在制作根文件系统时,使用的是经过裁剪之后的busybox,然而很多工具都没有添加到根文件系统内部(如:traceroute)。假设现在要使用traceroute工具,需按照如下步骤添加:

1. 下载busybox

     https://busybox.net/downloads/,这里下载的是 busybox-1.23.1.tar.bz2

2. 解压

    tar jxvf  busybox-1.23.1.tar.bz2  -C ./

3. 添加默认配置
    make defconfig


4. make menuconfig
    Busybox Setting ----->
    Build Options -----> 
        #a. 选择将busybox进行静态编译,根文件系统为只读的,只能将其工具编译成静态库,否则无法使用! 
        [*]Build BusyBox as a static binary (no shared libs) 
        #b. 指定交叉编译器,不同的交叉编译工具对应的路径不一样,可以通过which工具查看(如:which arm-none-linux-gnueabi-gcc) 
        (/opt/9G25/arm-2009q1/bin/arm-none-linux-gnueabi-)Cross Compiler prefix 

       -------------------------------------------------------------------------------------------------------------------

    进入menuconfig菜单选择traceroute


5. make CROSS_COMPILE=arm-none-linux-gnueabi-


6. make install


7. 在busybox-1.23.1\_install\目录下将生成traceroute工具

 

8. 将traceroute工具拷贝到嵌入式linux平台运行

[root@mike app]$./traceroute 
BusyBox v1.23.1 (2018-08-04 14:56:49 CST) multi-call binary.

Usage: traceroute [-46FIldnrv] [-f 1ST_TTL] [-m MAXTTL] [-p PORT] [-q PROBES]
        [-s SRC_IP] [-t TOS] [-w WAIT_SEC] [-g GATEWAY] [-i IFACE]
        [-z PAUSE_MSEC] HOST [BYTES]

Trace the route to HOST

        -4,-6   Force IP or IPv6 name resolution
        -F      Set the don't fragment bit
        -I      Use ICMP ECHO instead of UDP datagrams
        -l      Display the TTL value of the returned packet
        -d      Set SO_DEBUG options to socket
        -n      Print numeric addresses
        -r      Bypass routing tables, send directly to HOST
        -v      Verbose
        -m      Max time-to-live (max number of hops)
        -p      Base UDP port number used in probes
                (default 33434)
        -q      Number of probes per TTL (default 3)
        -s      IP address to use as the source address
        -t      Type-of-service in probe packets (default 0)
        -w      Time in seconds to wait for a response (default 3)
        -g      Loose source route gateway (8 max)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值