在shell中直接输入
export PATH=$PATH:/root/lede/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/bin
export STAGING_DIR=/root/lede/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16
export CC=mipsel-openwrt-linux-musl-gcc
export CXX=mipsel-openwrt-linux-musl-g++
export AR=mipsel-openwrt-linux-musl-ar
export RANLIB=mipsel-openwrt-linux-musl-ranlib
export ac_cv_linux_vers=4.4.61
# 在https://www.winpcap.org/devel.htm 下载winpcap源码
unzip source.zip
cd winpcap/wpcap/libpcap
chmod +x configure
./configure --build=x86_64-unknown-linux-gnu --host=mipsel-openwrt-linux --with-pcap=linux(这里build如果不知道,可以运行./conffigure,结果的第一行就是本机器)
make
# 在winpcap/wpcap/libpcap/pcap-int.h 里加上一行 #include <string.h> 否则在 strlcpy 处会报错
cd rpcapd
# 修改 Makefile
# 修改编译器,改成CC=mipsel-openwrt-linux-gcc
make
file rpcapd
export PATH=$PATH:/root/lede/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16/bin
export STAGING_DIR=/root/lede/staging_dir/toolchain-mipsel_24kc_gcc-5.4.0_musl-1.1.16
export CC=mipsel-openwrt-linux-musl-gcc
export CXX=mipsel-openwrt-linux-musl-g++
export AR=mipsel-openwrt-linux-musl-ar
export RANLIB=mipsel-openwrt-linux-musl-ranlib
export ac_cv_linux_vers=4.4.61
# 在https://www.winpcap.org/devel.htm 下载winpcap源码
unzip source.zip
cd winpcap/wpcap/libpcap
chmod +x configure
./configure --build=x86_64-unknown-linux-gnu --host=mipsel-openwrt-linux --with-pcap=linux(这里build如果不知道,可以运行./conffigure,结果的第一行就是本机器)
make
# 在winpcap/wpcap/libpcap/pcap-int.h 里加上一行 #include <string.h> 否则在 strlcpy 处会报错
cd rpcapd
# 修改 Makefile
# 修改编译器,改成CC=mipsel-openwrt-linux-gcc
make
file rpcapd
# rpcapd: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1, dynamically linked, interpreter /lib/ld-musl-mipsel-sf.so.1, not stripped
把生成的rpcapd拷贝到目标平台,可以直接运行。运行命令:
./rpcapd -n -b 192.168.1.176 -l 192.168.1.115