Looking to get the Winpcap developer pack (4.1.2) running on Windows 7 64-bit. I'm programming in C/C++ in the Netbeans IDE with the Cygwin (4.1.10) compiler. I'd like to directly pull some GPS data from UDP packets instead of using another program where I go through an intermediate step and pull them from a text file. If I can't sort this out I'm gonna try in Ubuntu next and see if I can get libpcap working there (even though Windows is preferred because of other equipment I am using). Here's where I'm at (my main resources have been gathered from Introduction to the WinPcap Networking Libraries, Using WinPcap in your programs, and Programming with pcap at tcpdump.org (note: I can't post the third link because it says my reputation needs to be higher)):
- I've installed the winpcap developers pack to C:\Users\\Documents
- I've installed the winpcap dll (though I'm not actually sure why this is necessary since all of the documentation I've seen only seems to use the .lib files)
- As instructed from the above links I've added the following settings in my project:
- For the "Include Directories and Headers" I put the path to the winpcap Include folder from the developer pack
- For "Preprocessor Definitions" I've added HAVE_REMOTE and WPCAP
- For "Additional Library Directories" I put the path to the winpcap Lib folder from the developer pack
By doing all of the above and including the pcap.h header with no additional code I can compile my program. However, the install instructions I've been referencing also state to add the following two "Additional Dependencies": winpcap.lib and Packet.lib
As soon as I do that I can't compile and get the following:
make[2]: Entering directory '/cygdrive/c/Users/<user>/Documents/NetBeansProjects/GPS_Parcer'
make[2]: *** No rule to make target 'winpcap.lib', needed by 'dist/Debug/Cygwin_4.x-Windows/gps_parcer.exe'. Stop.
make[2]: Leaving directory '/cygdrive/c/Users/<user>/Documents/NetBeansProjects/GPS_Parcer'
nbproject/Makefile-Debug.mk:61: recipe for target '.build-conf' failed
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory '/cygdrive/c/Users/<user>/Documents/NetBeansProjects/GPS_Parcer'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make: *** [.build-impl] Error 2
Out of curiosity to see if those dependencies actually mattered I removed them and then added some basic code I copied from tcpdump.org:
#include <stdio.h>
#include <pcap.h>
int main(int argc, char *argv[])
{
char *dev, errbuf[PCAP_ERRBUF_SIZE];
dev = pcap_lookupdev(errbuf); //error is here!
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 undefined reference to 'pcap_lookupdev'
error.
I've also read that possibly Winpcap will only work with MS Visual Studio stuff so I actually don't know if that's true.
Sorry for the long write-up, but if anybody has some insights or experience with this it would be much appreciated.