Linux中在x86架构下交叉编译ARM架构的tcpdump
准备交叉编译工具
gcc-linaro-5.4.1-2017.01-x86_64_aarch64-linux-gnu.tar.xz
交叉编译工具百度网盘链接 提取码:kxnr
解压出来
tar xf gcc-linaro-5.4.1-2017.01-x86_64_aarch64-linux-gnu.tar.xz
添加编译器路径,这里我将交叉编译工具放置在了/opt目录下
PATH=$PATH:/opt/gcc-linaro-5.4.1-2017.01-x86_64_aarch64-linux-gnu/bin
准备两个包
- libpcap-1.5.3.tar.gz
- tcpdump-4.5.1.tar.gz
libpcap-1.5.3百度网盘链接 提取码:trya
tcpdump-4.5.1百度网盘链接
提取码:o8r5
解压出来
tar xf libpcap-1.5.3.tar.gz
tar xf tcpdump-4.5.1.tar.gz
编译libpcap
cd libpcap-1.5.3
mkdir build
./configure --prefix=/home/test/package/libpcap-1.5.3/build --host=arm-linux CC=aarch64-linux-gnu-gcc
构建的时候会报错
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
重新构建
./configure --prefix=/home/test/package/libpcap-1.5.3/build --host=arm-linux CC=aarch64-linux-gnu-gcc
编译
make
make install
编译tcpdump
cd ../tcpdump-4.5.1
mkdir build
./configure --prefix=/home/test/package/libpcap-1.5.3/build --host=arm-linux CC=aarch64-linux-gnu-gcc
构建的时候会报错
configure: error: cannot determine linux version when cross-compiling
编辑configure文件将,注释报错相关的那三行
#if test $ac_cv_linux_vers = unknown ; then
# as_fn_error $? "cannot determine linux version when cross-compiling" "$LINENO" 5
#fi
重新构建
./configure --prefix=/home/test/package/tcpdump-4.5.1/build --host=arm-linux CC=aarch64-linux-gnu-gcc
编译
make
make install
此时在tcpdump-4.5.1目录下就生成tcpdump了