Reputation: 319
I am developing for OSX 10.8. I just installed libpcap
via MacPorts and tried running a simple device hunter (below)
#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);
}
and while trying to compile with g++ i am getting:
Undefined symbols for architecture x86_64:
"_pcap_lookupdev", referenced from:
_main in ccIMp1m2.o
Any helpful advice so I can actually get started with learning this stuff would be great! I googled for a solid 10-15 minutes but just couldn't find much on my particular issue with my setup.
Upvotes: 2
Views: 2486
Reputation: 224844
You need to link libpcap
. Probably -lpcap
added to your compiler command line will work. If it's installed somewhere strange (and it might be, since you got it from MacPorts), you might need -L/path/to/libpcap -lpcap
.
Upvotes: 8