Pcap functions have an "undefined link"

I am trying to go through this tutorial: http://www.tcpdump.org/pcap.html

Now I install pcap (code hints and everything that works) using:

sudo apt-get install libpcap-dev 

and so far I have the following code (file name example_pcap.c):

 #include <stdio.h> #include <pcap.h> int main(int argc, char *argv[]) { char *dev, errbuf[PCAP_ERRBUF_SIZE]; dev = pcap_lookupdev(errbuf); return 0; } 

For many of the issues that I have already seen, they said to compile it using this:

 gcc -lpcap example_pcap.c -o example_pcap 

However, I still get the following error:

 example_pcap.c:(.text+0x32): undefined reference to `pcap_lookupdev' 
+5
source share
1 answer
+12
source

Source: https://habr.com/ru/post/1207600/


All Articles