Ubuntu16.04 install libpcap安装和测试
发布日期:2021-09-30 05:17:05 浏览次数:1 分类:技术文章

本文共 823 字,大约阅读时间需要 2 分钟。

1.官网下载安装包:

2.开始配置

cd libpcap-1.9.0./configure

报错1:configure: error: Neither flex nor lex was found.

解决1:sudo apt-get install flex

报错2:configure: error: yacc is insufficient to compile libpcap.

libpcap requires Bison, a newer version of Berkeley YACC with support
解决2: sudo apt-get install -y byacc

makesudo make install

3.创建链接

报错3:虽然可以成功编译文件,但是在运行的时候却提示

1.cpp:(.text+0x43):对‘pcap_lookupdev’未定义的引用
解决3:这是因为libpcap.so.1默认安装到了/usr/local/lib下,我们做一个符号链接到/usr/lib/下即可。

sudo ln -s /usr/local/lib/libpcap.so.1 /usr/lib/libpcap.so.1

4.测试

#include 
#include
int main(){ char errBuf[PCAP_ERRBUF_SIZE], * device; device = pcap_lookupdev(errBuf); if(device) { printf("success: device: %s\n", device); } else { printf("error: %s\n", errBuf); } return 0;}

输入以下代码:

g++ test.c -o test -lpcap

5.效果

在这里插入图片描述

转载地址:https://blog.csdn.net/huoxingrenhdh/article/details/86721320 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:initramfs:The root filesystem on /dev/sda2 requires a manual fsck
下一篇:tcpdump基本指令的使用

发表评论

最新留言

关注你微信了!
[***.104.42.241]2024年04月11日 15时17分47秒