|
1. 交叉编译
编译tcpdump需要提前下载libpcap,这两个库都可以在tcpdump官网上进行下载,链接如下:
http://www.tcpdump.org/#mailing-lists
1.1 编译libpcap
交叉编译libpcap,libpcap支持CMake,既可以使用configure进行编译,也可以使用cmake
cmake .. -DCMAKE_TOOLCHAIN_FILE=XXXX.cmake -DCMAKE_INSTALL_PREFIX=XXXX
或者
./configure --host=arm-himix200-linux ac_cv_linux_vers=2 CC=arm-himix200-linux-gcc
(如果需要安装可以添加上--prefix= XXXX)
1.2 编译tcpdump
交叉编译tcpdump,如INSTALL.txt中所说:
After libpcap has been built (either install it with "make install" or make sure both the libpcap and tcpdump source trees are in the same directory), run ./configure (a shell script). "configure" will determine your system attributes and generate an appropriate Makefile from Makefile.in. Now build tcpdump by running "make".
tcpdump需要依赖libpcap,有两种方式满足依赖:(1)libpcap和tcpdump代码在同一级目录下 (2)指定libpcap的路径
/configure --host=arm-himix200-linux ac_cv_linux_vers=2 --with-system-libpcap=XXXX/libpcap/lib 此外,github上下载的最新版tcpdump也支持CMake,编译命令如下:
cmake .. -DCMAKE_TOOLCHAIN_FILE=XXXX/arm-himix200-linux.cmake -DPCAP_INCLUDE_DIR=XXXX/prefix/libpcap/include -DPCAP_LIBRARY=XXXX/prefix/libpcap/lib |