一、编译依赖库libpcap
1.下载libpcap
下载路径:http://www.tcpdump.org/release/libpcap-1.9.1.tar.gz
2.configure配置
./configure CC=arm-histbv320-linux-gcc --host=arm-histbv320-linux --prefix=/home/xxx/0723/TVOS_DBS/platform/linux_h5/jznginx
3.make make install
make
make install
二、编译依赖库ncurses
1.下载ncurses
下载路径:http://ftp.gnu.org/gnu/ncurses/ncurses-6.0.tar.gz
2.configure配置
./configure CC=arm-histbv320-linux-gcc --host=arm-histbv320-linux --prefix=/home/xxx/0723/TVOS_DBS/platform/linux_h5/jznginx --with-shared
3.make make install
make
make install
三、编译iftop
1.下载iftop
下载路径:http://www.ex-parrot.com/~pdw/iftop/download/iftop-0.17.tar.gz
2.configure配置
./configure CC=arm-histbv320-linux-gcc --host=arm-histbv320-linux --prefix=/home/xxx/0723/TVOS_DBS/platform/linux_h5/jznginx
注意:configure过程中肯定会报很多错误,只需要将这些报错的check统统注释掉,在生成的Makefile中手动添加链接库和头文件的路径就行。
3.Makefile的改动
a.修改LDFLAGS:LDFLAGS = -L/home/xxx/0723/TVOS_DBS/platform/linux_h5/jznginx/lib/ 该路径为ncurses和libpcap动态库的位置
b.修改CPPFLAGS:CPPFLAGS = -I/home/xxx/0723/TVOS_DBS/platform/linux_h5/jznginx/include/ncurses/ -I/home/xxx/0723/TVOS_DBS/platform/linux_h5/jznginx/include/pcap/
c.修改LIBS:LIBS = -lpcap -lm -lncurses -lpthread
4.修改报错文件iftop.c
将头部对libpcap的引用由:
#if defined(HAVE_PCAP_H)
# include <pcap.h>
#elif defined(HAVE_PCAP_PCAP_H)
# include <pcap/pcap.h>
#else
# error No pcap.h
#endif
改为:
# include <pcap/pcap.h>
5.make、make install
make
make install
四、编译之后路径文件说明
1.在/home/xxx/0723/TVOS_DBS/platform/linux_h5/jznginx/lib/
libpcap.so ln--> libpcap.so.1.9.1
libncurses.so ln--> libncurses.so.6.0
2.在/home/xxx/0723/TVOS_DBS/platform/linux_h5/jznginx/sbin/
iftop
3.在/home/xxx/0723/TVOS_DBS/platform/linux_h5/jznginx/share/
man/ tabset/ terminfo/
五、开发版上的使用
拷贝步骤四中描述的编译生成的文件至U盘,利用U盘将库文件放在开发板的/usr/lib/目录,bin文件iftop放在/usr/sbin/
cp /mnt/sda/sda1/libpcap.so /usr/lib/
cp /mnt/sda/sda1/libpcap.so.1.9.1 /usr/lib/
cp /mnt/sda/sda1/libncurses.so /usr/lib/
cp /mnt/sda/sda1/libncurses.so.6.0 /usr/lib/
cp /mnt/sda/sda1/iftop /usr/sbin/
cp /mnt/sda/sda1/share/man/ /usr/share -rf
cp /mnt/sda/sda1/share/tabset/ /usr/share -rf
cp /mnt/sda/sda1/share/terminfo/ /usr/share -rf
chmod 755 /usr/sbin/iftop
export TERMINFO=/usr/share/terminfo
cd /usr/sbin/
./iftop
来源:CSDN
作者:nisinongnong
链接:https://blog.csdn.net/nisinongnong/article/details/104036967