iftop交叉编译(ncurses-5.9、pcap-1.8.1、iftop-1.0)

一、iftop依赖ncurses,所以先编译ncurses

https://mp.csdn.net/mp_blog/creation/editor/125993627https://mp.csdn.net/mp_blog/creation/editor/125993627这篇文章已经写过如何编译

二、iftop还依赖pcap,所以还要编译pcap
Index of /releasehttps://www.tcpdump.org/release/

从上方链接中下载源码并进入下载目录,执行提前准备好的build.sh脚本

​
#!/bin/sh

HOST=arm-linux-gnueabihf
DIR=$PWD/install
CC=/opt/a1000/toolchain/app/ext-toolchain/bin/arm-linux-gnueabihf-gcc
AR=/opt/a1000/toolchain/app/ext-toolchain/bin/arm-linux-gnueabihf-ar
RANLIB=/opt/a1000/toolchain/app/ext-toolchain/bin/arm-linux-gnueabihf-ranlib
STRIP=/opt/a1000/toolchain/app/ext-toolchain/bin/arm-linux-gnueabihf-strip

if [ ! -d ${DIR} ]; then
        mkdir -p ${DIR}
else
        rm -rf install/*
fi

./configure \
        --host=${HOST} \
        --prefix=${DIR} \
        CC=${CC} \
        AR=${AR} \
        RANLIB=${RANLIB}

if [ $? -eq 0 ]; then
        make && make install
fi​

在./configure的时候报错了。。。

configure: error: pcap type not determined when cross-compiling; use --with-pcap=...

把configure文件中的下面几行注释掉就行

#if test -z "$with_pcap" && test "$cross_compiling" = yes; then
#       as_fn_error $? "pcap type not determined when cross-compiling; use --with-pcap=..." "$LINENO" 5
#fi

再次执行build.sh脚本后,就会在install/lib目录下生成需要的库文件。

三、编译iftop

下载源码并进入下载目录,执行提前准备好的build.sh脚本

#!/bin/sh

HOST=arm-linux-gnueabihf
DIR=$PWD/install
CC=/opt/a1000/toolchain/app/ext-toolchain/bin/arm-linux-gnueabihf-gcc
AR=/opt/a1000/toolchain/app/ext-toolchain/bin/arm-linux-gnueabihf-ar
RANLIB=/opt/a1000/toolchain/app/ext-toolchain/bin/arm-linux-gnueabihf-ranlib
STRIP=/opt/a1000/toolchain/app/ext-toolchain/bin/arm-linux-gnueabihf-strip

if [ ! -d ${DIR} ]; then
        mkdir -p ${DIR}
else
        rm -rf install/*
fi

./configure \
        --host=${HOST} \
        --prefix=${DIR} \
        CC=${CC} \
        AR=${AR} \
        RANLIB=${RANLIB} \
        --with-libpcap=/home/ylkuai/project/libpcap-1.8.1/install \
        LDFLAGS=-L/home/ylkuai/project/ncurses-5.9/install/lib \
        CPPFLAGS=-I/home/ylkuai/project/ncurses-5.9/install/include

if [ $? -eq 0 ]; then
        make && make install
fi

没编通,报错了

checking for a curses library containing mvchgat... none found
configure: error: Curses! Foiled again!
  (Can't find a curses library supporting mvchgat.)
  Consider installing ncurses.

把configure文件中的这几行注释了

#if test x$foundcurseslib = x ; then
#    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none found" >&5
#$as_echo "none found" >&6; }
#    as_fn_error $? "Curses! Foiled again!
#  (Can't find a curses library supporting mvchgat.)
#  Consider installing ncurses." "$LINENO" 5
#else
#    { $as_echo "$as_me:${as_lineno-$LINENO}: result: -l$foundcurseslib" >&5
#$as_echo "-l$foundcurseslib" >&6; }
#fi

make的时候报错了。。找不到头文件

edline.c:10:20: fatal error: curses.h: No such file or directory
compilation terminated.
Makefile:529: recipe for target 'edline.o' failed
make[2]: *** [edline.o] Error 1
make[2]: Leaving directory '/home/ylkuai/tardir/iftop-1.0pre4'
Makefile:592: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/ylkuai/tardir/iftop-1.0pre4'
Makefile:400: recipe for target 'all' failed
make: *** [all] Error 2

改一下makefile

CPPFLAGS = -I/home/ylkuai/project/ncurses-5.9/install/include -I/home/ylkuai/project/libpcap-1.8.1/install/include
改成下面这样
CPPFLAGS = -I/home/ylkuai/project/ncurses-5.9/include -I/home/ylkuai/project/libpcap-1.8.1/install/include

直接make再make install就成功了

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值