链接 pcap.h 时出现问题

链接 pcap.h 时出现问题

我正在尝试编译 ethping
以下是通过 make 发出的命令:

gcc -Wall -Werror -ggdb -g -O2 -lpcap  -o ethping ethping.o ieee8021ag.o dot1ag_eth.o

我现在收到此错误信息:

/dot1ag-utils-master/src/ethping.c:65: undefined reference to `pcap_breakloop'

表明它无法找到pcap.h

所以我输入:

root:src# whereis pcap.h
pcap: /usr/include/pcap.h /usr/include/pcap /usr/share/man/man3/pcap.3pcap.gz
root:src# 



root:src# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/include

/usr/include绝对在我的路上。

唯一可能有问题的是,这/usr/include/pcap.h是一个包含的存根文件pcap/pcap.h

/*
 * For backwards compatibility.
 *
 * Note to OS vendors: do NOT get rid of this file!  Many applications
 * expect to be able to include <pcap.h>, and at least some of them
 * go through contortions in their configure scripts to try to detect
 * OSes that have "helpfully" moved pcap.h to <pcap/pcap.h> without
 * leaving behind a <pcap.h> file.
 */
#include <pcap/pcap.h>

因此/usr/include/pcap/pcap.h实际的文件内容中存在这些定义。

答案1

您不仅需要安装头文件,还需要安装库。这些包以 结尾-dev,因此在本例中:

sudo apt-get install libpcap-dev

顺便说一下,这是一个元包,它将安装libpcap0.8-dev包。

相关内容