1、在linux系统上我们需要先后安装与tcpdump安装相关的三个依赖程序:
sudo apt-get install m4
sudo apt-get install bison
sudo apt-get install flex
2、创建两个文件夹分别用来保存源文件和生成文件:tcpdumpsrc和tcpdumptools,去官网下载最新的源码,并解压到tcpdumpsrc中,最新的版本发中下图所示
3 tcpdump的编译阶段会用到libpcap的一些文件,故先编译libpcap,经典的3步骤:
./configure --prefix=/home/monkey/tcpdump/tcpdumptools/ --host=arm-linux --target=arm-linux CC=arm-none-linux-gnueabi-gcc
make
make install
其中:prefix代表指定安装目录;host指定系统编译平台;target指定系统运行平台;CC指定所用的交叉编译工具链
4 编译tcpdump
./configure --prefix=/home/monkey/tcpdump/tcpdumptools/ --host=arm-linux --target=arm-linux CC=arm-none-linux-gnueabi-gcc
makemake install
5 生成文件
6 可能出现的错误:
(1)
#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
(2)
#if test $ac_cv_linux_vers = unknown ; then
#{ { echo "$as_me:$LINENO: error: cannot determine linux version when cross-compiling" >&5
#echo "$as_me: error: cannot determine linux version when cross-compiling" >&2;}
#{ (exit 1); exit 1; }; }
#fi