/* grab a device */
dev = pcap_lookupdev(errbuf);
if(dev == NULL) {
fprintf(stderr,"%s\n",errbuf);
exit(1);
}
/* ask pcap for the network address and mask of the device */
pcap_lookupnet(dev,&netp,&maskp,errbuf);
/* open device for reading this time lets set it in promiscuous
* mode so we can monitor traffic to another machine */
descr = pcap_open_live(dev,BUFSIZ,1,-1,errbuf);
if(descr == NULL) {
printf("pcap_open_live(): %s\n",errbuf);
exit(1);
}
/* Lets try and compile the program.. non-optimized */
if(pcap_compile(descr,&fp,argv[1],0,netp) == -1) {
fprintf(stderr,"Error calling pcap_compile\n");
exit(1);
}
/* set the compiled program as the filter */
if(pcap_setfilter(descr,&fp) == -1) {
fprintf(stderr,"Error setting filter\n");
exit(1);
}
此程序运行时还有1.o: In function `main':
/root/capture/capture/1.c:55: undefined reference to `pcap_lookupdev'
/root/capture/capture/1.c:62: undefined reference to `pcap_lookupnet'
/root/capture/capture/1.c:73: undefined reference to `pcap_compile'
/root/capture/capture/1.c:85: undefined reference to `pcap_loop'
collect2: ld returned 1 exit status
的错误,不知怎么调试.