error: undefined reference to `pcap_next_ex
Hi,
I tried to execute a code which I downloaded.
here is the code
#include <pcap.h>
#include <stdio.h>
int main()
{
pcap_t *handle; /* Session handle */
char errbuf[PCAP_ERRBUF_SIZE]; /* Error string */
struct pcap_pkthdr *header; /* The header that pcap gives us */
const u_char *packet; /* The actual packet */
/* Open the session in promiscuous mode */
handle = pcap_open_live("eth0", 65000, 0, 0, errbuf);
if (handle == 0) {
printf("Error in pcap_open_live: %s",errbuf);
exit(1);
}
/* Grab a packet */
int code = pcap_next_ex(handle, &header, &packet);
if (code < 0)
printf("Error in pcap_next_ex\n");
/* Print its length */
printf("Jacked a packet with length of %d",header->len );
/* And close the session */
pcap_close(handle);
return(0);
}
When I compiled the code I got this error:
[root@CORE-2-02 examples]# gcc without2.c -lpcap
without2.c:31:2: warning: no newline at end of file
/tmp/cc0uKpD3.o(.text+0x72): In function `main':
: undefined reference to `pcap_next_ex'
collect2: ld returned 1 exit status
Can anybody say what is the problem.
I get this error whenever i use exported functions from pcap library
thanks and regards
cynthia thomas
|