移植 iftop 到海思 3559 平台
一、下载
http://www.ex-parrot.com/~pdw/iftop/
二、编译
报错 1
configure: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used.
checking build system type... x86_64-unknown-linux-gnu
checking host system type... Invalid configuration `aarch64-himix100-linux': machine `aarch64-himix100' not recognized
configure: error: /bin/sh config/config.sub aarch64-himix100-linux failed
解决 1
在 config/config.sub 文件的第 231 行后面加一行 | aarch64-himix100 \ 就能认到了
# Decode aliases for certain CPU-COMPANY combinations.
case $basic_machine in
# Recognize the basic CPU types without company name.
# Some are omitted here because they have special meanings below.
1750a | 580 \
| a29k \
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
| aarch64-himix100 \
| c4x | clipper \
| d10v | d30v | dlx | dsp16xx \
| fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \
| ip2k \
| m32r | m68000 | m68k | m88k | mcore \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
报错 2
checking where to find pcap.h... /usr/include
checking for pcap_open_live in -lpcap... no
configure: error: can't find libpcap
You're not going to get very far without libpcap.
解决 2
使用 --with-libpcap 引入交叉编译好的库--with-libpcap=/hisi_ext/3rd/libpcap-1.9.1/_install
报错 3
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.
分析 3
这个问题网上千篇一律的都是说安装库,但是我们这是交叉编译,直接命令安装库的方法是用不了的。
很显然,解决这个问题的重点就是如何正确引入 ncurses 相关项。
我一开始只是添加了 --with-ncurses=/hisi_ext/3rd/ncurses-6.2/_install LDFLAGS="-L/hisi_ext/3rd/ncurses-6.2/_install/lib -lncurses" CPPFLAGS="-I/hisi_ext/3rd/ncurses-6.2/_install/include" 这些项,头文件路径,库文件路径,库文件都正确引入了,但是仍然报一样的错误。理论上我已经引入了 ncurses ,应该不会有问题的。于是我仔细看了一下 configure 文件里是如何判断失败的,如何拷贝里面的判断方法,自己在外面手动编译一下才发现少引用了一个头文件路径 -I/hisi_ext/3rd/ncurses-6.2/_install/include/ncurses
测试
- 创建 main.c
$ cat main.c
#include <curses.h>
int main ()
{
mvchgat(0, 0, 1, A_REVERSE, 0, NULL) ;
return 0;
}
- 编译 main.c
$ aarch64-himix100-linux-gcc main.c -lncurses -L/hisi_ext/3rd/ncurses-6.2/_install/lib -I/hisi_ext/3rd/ncurses-6.2/_install/include/ncurses
In file included from main.c:1:0:
/hisi_ext/3rd/ncurses-6.2/_install/include/ncurses/curses.h:61:33: fatal error: ncurses/ncurses_dll.h: No such file or directory
#include <ncurses/ncurses_dll.h>
^
compilation terminated.
竟然报错,猜测 configure 文件里只要报错就算作失败,不管错误原因是什么,都是抛出一样的错误 ... Can't find a curses library supporting mvchgat ...。我们可以在 ncurses 路径里面找到缺失的 ncurses_dll.h 文件,如下:
$ ls ../ncurses-6.2/_install/include/ncurses
curses.h cursesf.h cursesp.h cursslk.h etip.h menu.h ncurses.h panel.h term_entry.h tic.h
cursesapp.h cursesm.h cursesw.h eti.h form.h nc_tparm.h ncurses_dll.h term.h termcap.h unctrl.h
所以引入这个新路径就可以编译通过
解决 3
./configure --prefix=/hisi_ext/3rd/iftop-0.17/_install\
--host=aarch64-himix100-linux\
--with-libpcap=/hisi_ext/3rd/libpcap-1.9.1/_install\
--with-ncurses=/hisi_ext/3rd/ncurses-6.2/_install\
LDFLAGS="-L/hisi_ext/3rd/ncurses-6.2/_install/lib -lncurses"\
CPPFLAGS="-I/hisi_ext/3rd/ncurses-6.2/_install/include/ncurses -I/hisi_ext/3rd/ncurses-6.2/_install/include"
三、安装
make
make install
四、使用
拷贝 iftop 到开发板后,运行
/mnt/wzy # ./iftop
./iftop: error while loading shared libraries: libpcap.so.1: cannot open shared object file: No such file or directory
解决:拷贝对应库到开发板的环境变量的 LD_LIBRARY_PATH 路径
用法
/mnt/wzy # ./iftop -h
iftop: display bandwidth usage on an interface by host
Synopsis: iftop -h | [-npbBP] [-i interface] [-f filter code] [-N net/mask]
-h display this message
-n don't do hostname lookups
-N don't convert port numbers to services
-p run in promiscuous mode (show traffic between other
hosts on the same network segment)
-b don't display a bar graph of traffic
-B Display bandwidth in bytes
-i interface listen on named interface
-f filter code use filter code to select packets to count
(default: none, but only IP packets are counted)
-F net/mask show traffic flows in/out of network
-P show ports as well as hosts
-m limit sets the upper limit for the bandwidth scale
-c config file specifies an alternative configuration file
iftop, version 0.17
copyright (c) 2002 Paul Warren <pdw@ex-parrot.com> and contributors
测试
/mnt/wzy # ./iftop -i eth0
interface: eth0
IP address is: 192.168.12.150
MAC address is: 00:0c:29:58:00:50
Error opening terminal: xterm.
解决:拷贝你交叉编译出来的 ncurses 目录到开发板,并修改环境变量为对应路径和值:
/mnt/wzy # env | grep -i term
TERMINFO=/mnt/wzy/ncurses-6.2/share/terminfo
TERM=xterm
四、用法略解
执行 ./iftop -i eth0 后串口终端显示结果(会动态刷新)如下所示:
19.1Mb 38.1Mb 57.2Mb 76.3Mb 95.4Mb
└────────────────┴─────────────────┴────────────────┴─────────────────┴─────────────────
192.168.12.150 => 192.168.12.128 12.2Mb 12.2Mb 12.3Mb
192.168.12.150 => 192.168.12.106 12.2Mb 12.2Mb 12.3Mb
192.168.12.150 => 192.168.12.69 8.04Mb 8.04Mb 8.19Mb
192.168.12.255 => 192.168.12.152 0b 0b 0b
10.0.1.255 => 10.0.1.15 0b 0b 0b
10.69.2.255 => 10.69.2.152 0b 0b 0b
192.168.12.150 => 192.168.12.133 0b 42b 10b
10.69.2.255 => 10.69.2.43 0b 0b 0b
192.168.12.255 => 192.168.12.43 0b 0b 0b
255.255.255.255 => 10.69.2.69 0b 0b 0b
────────────────────────────────────────────────────────────────────────────────────────
TX: cumm: 278MB peak: 40.7Mb rates: 32.5Mb 32.4Mb 32.9Mb
RX: 1.03MB 152Kb 122Kb 123Kb 125Kb
TOTAL: 279MB 40.8Mb 32.6Mb 32.5Mb 33.0Mb
h 或 ? 显示帮助信息
Host display: General:
n - toggle DNS host resolution P - pause display
s - toggle show source host h - toggle this help display
d - toggle show destination host b - toggle bar graph display
t - cycle line display mode B - cycle bar graph average
T - toggle cummulative line totals
Port display: j/k - scroll display
N - toggle service resolution f - edit filter code
S - toggle show source port l - set screen filter
D - toggle show destination port L - lin/log scales
p - toggle port display ! - shell command
q - quit
Sorting:
1/2/3 - sort by 1st/2nd/3rd column
< - sort by source name
> - sort by dest name
o - freeze current order
iftop, version 0.17
- 分享
- 举报
-
浏览量:1073次2024-01-04 17:47:00
-
浏览量:582次2024-01-24 14:47:22
-
浏览量:7308次2021-03-18 08:54:25
-
浏览量:1621次2020-08-10 19:19:56
-
浏览量:637次2024-01-02 16:51:15
-
浏览量:562次2023-11-08 13:43:24
-
浏览量:4467次2020-07-31 13:45:09
-
浏览量:1376次2023-11-04 15:07:11
-
浏览量:5673次2020-08-26 14:15:06
-
浏览量:1029次2024-01-03 17:15:03
-
浏览量:1093次2023-10-13 10:22:12
-
浏览量:3244次2019-02-14 17:57:04
-
浏览量:4904次2021-04-17 18:58:36
-
浏览量:3629次2023-12-02 14:17:30
-
浏览量:2153次2020-04-21 20:27:00
-
浏览量:3387次2020-04-21 20:28:40
-
浏览量:2831次2020-08-10 19:14:51
-
浏览量:960次2023-09-01 13:29:58
-
浏览量:591次2024-02-23 17:34:00
-
广告/SPAM
-
恶意灌水
-
违规内容
-
文不对题
-
重复发帖
张显显
感谢您的打赏,如若您也想被打赏,可前往 发表专栏 哦~
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明