LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   pcap error (http://www.linuxquestions.org/questions/programming-9/pcap-error-556488/)

ilnli 05-24-2007 07:09 PM

pcap error
 
Hi,

I'm trying to execute the following code

#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);
}


but it is giving me the following error however I've install libpcap

/root/Projects/test/src/main.c:11: undefined reference to 'pcap_lookupdev'


I can't understand the problem.

regards,
Imran

thanks

crabboy 05-25-2007 08:22 AM

Did you reference the pcap library on the compile line?
Code:

cc pcaptest.c -lpcap

ilnli 05-26-2007 06:47 PM

thanks a lot mate it worked


All times are GMT -5. The time now is 09:02 AM.