Results 1 to 2 of 2
hi .. im having trouble writing a simple snippet using pcap.h
even when i try to compile a simple code like :
#include <stdio.h>
#include <pcap.h>
int main(int argc, char ...
- 05-15-2009 #1Just Joined!
- Join Date
- May 2009
- Posts
- 1
Libpcap problem !!! Urgent
hi .. im having trouble writing a simple snippet using pcap.h
even when i try to compile a simple code like :
#include <stdio.h>
#include <pcap.h>
int main(int argc, char *argv[])
{
char *dev, errbuf[PCAP_ERRBUF_SIZE];
dev = pcap_lookupdev(errbuf);
if (dev == NULL) {
fprintf(stderr, "Couldn't find default device: %s\n", errbuf);
return(2);
}
printf("Device: %s\n", dev);
return(0);
}
.. i get an error saying undefined reference to "pcap_lookupdev".
Even if i try a longer code .. i get the same error for each of the pcaps functionalities i have used (pcap_open_live, pcap_loop, etc).
I downloaded the pcap folder from tcpdump.org and pasted it in my usr/include. All include files are in order as far as i know.
I have 2 days left to my project deadline .. someone please help .. thanks alot .. cheers
- 05-15-2009 #2Just Joined!
- Join Date
- May 2009
- Posts
- 5
This error seems to be coming because linker is unable to find the library. After downloading and unzippping, you should have got a libpcap.so file in the same folder.
I'd suggest you two things to do:
1. export LD_LIBRARY_PATH=absolute_path_of_pcap_lib:$LD_LIBR ARY_PATH
OR
2. In the compilation command, add "-lpcap" at the end of command.
HTH,
Bluehive


Reply With Quote
