实战tcpdump4.99.4交叉编译

主要是记录交叉编译的一个坑,不知道为什么网上的教程都没遇到过。

环境

  • libpcap 1.10.4
  • tcpdump 4.99.4
  • WSL

编译步骤

注意事项

  1. 注意解压的时候文件夹名需要是libpcap-1.10.4,由于我是在github直接下载zip的压缩包名是libpcap-libpcap-1.10.4.tar.gz解压后libpcap-libpcap-1.10.4,编译tcpdump时会出现问题找不到libpcap
  2. libpcap-1.10.4和tcpdump-4.99.4需要放在同一级目录下
1.编译libpcap
  1. tar zxvf libpcap-1.10.4.tar.gz
  2. cd libpcap-1.10.4
  3. ./configure --prefix=$PWD/install --host=arm CC=/opt/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
  4. make
  5. make install
2.编译tcpdump(默认是静态链接)
  1. tar zxvf tcpdump-4.99.4.tar.gz

  2. cd tcpdump-4.99.4.tar.gz

  3. ./configure --prefix=$PWD/install --host=arm CC=/opt/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc

  4. make 可能会提示错误如下:

    /opt/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -DHAVE_CONFIG_H -I. -I.../libpcap-1.10.4 -g -O2 -c ./tcpdump.c

    In file included from /opt/gcc-linaro-5.4.1-2017.05-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/include/string.h:634:0,

    from ./tcpdump.c:117:

    ./netdissect.h:133:14: error: expected identifier or '(' before 'extension '

    extern char *strdup (const char *str);

    ^

    ./netdissect.h:137:14: error: expected identifier or '(' before 'extension '

    extern char *strsep(char **, const char *);

    那就去修改Makefile的INCLS

    makefile 复制代码
    INCLS = -I. -I../libpcap-1.10.4/install/include
  5. make install

相关推荐
七歌杜金房17 小时前
我终于又有了自己的 Linux 电脑
linux·debian·mac
tntxia2 天前
linux curl命令详解_curl详解
linux
扛枪的书生2 天前
Linux 网络管理器用法速查
linux
顺风尿一寸2 天前
Java Socket 内核之旅:从 SocketChannel.read() 到 tcp_recvmsg 与 epoll 的完整调用链路
linux
XIAOHEZIcode2 天前
Ubuntu 终端美化全栈指南:Bash 到 Kitty 踩坑实录
linux·ubuntu·命令行
唐青枫2 天前
别再只会用 cron:Linux systemd Timer 定时任务实战详解
linux
AlfredZhao4 天前
生产环境里,为什么不建议把普通端口直接暴露到公网?
linux·https·443·80
戴为沐5 天前
Linux内存扩容指南
linux
zylyehuo6 天前
Linux 彻底且安全地删除文件
linux
用户805533698036 天前
主线 U-Boot 上 RK3506:和闭源 rkbin 拔河的三个隐性契约
linux·嵌入式