I’m using Dev C++ on windows 7, and WinPcap (developer’s pack). Dev c++ is not able to find pcap.h apparently, even though I include the /include/ directory in project options, on compilation it displays an error saying “pcap.h: no such file or directory.” (along with many other errors).
Here is my code:
#include <stdlib.h>
#include <stdio.h>
#include <pcap.h>
int main(int argc, char **argv)
{
pcap_t *fp;
char errbuf[PCAP_ERRBUF_SIZE];
u_char packet[100];
return 0;
}
I’ve kept it simple. I was originally working in Visual Studio (C++), but distributing code compiled with Visual C++ requires Microsoft C Runtime library to be installed on the target system. I just want to be able to distribute the final executable and get it to work on any machine.
I checked the commmand line given to compiler. It did have the -I [path] option. Well is there anything I’m missing?
As a side note: I had compiled the above code with g++ (from dev c++ installation dir), and it compiled correctly. But when I tried to link it, the executable produced, just crashed on being run.
Your question is a little unclear, but your side-note makes it sound as if you could compile this (i.e. the
pcap.hheader was found) and your issues is with linking.To add directories to the search path for libraries use
-LPATHwherePATHis the actual directory containinglibpcap. To actually add it to the link use-lpcapin the linker call, e.g.