Reputation: 10468
I'm working on Fedora 17 and I want to program with libpcap. The problem is that my computer isn't finding pcap.h, which is really wierd since I've installed libpcap and libpcap-devel. Also wireshark and snort works on my station which I believe uses that library. So when I compile my code with ...
#include <pcap.h>
... Code
And use gcc my_file.c -lpcap, I get compiler errors that say ... can't find pcap.h. Whats odd is that I see my libpcap.so files in /libraries/ directory. I've done ..
yum install libpcap and yum install libpcap-devel
I don't know why Fedora is doing this to me.
Thanks for any help!
Upvotes: 9
Views: 57710
Reputation: 319
To execute the program in c++:
for c++ program
g++ program_name.cpp -lpcap
Upvotes: 0
Reputation: 3009
Try
~$ whereis pcap
Then as mata said
gcc -lpcap -I{path} file.c
where {path}
is the path that whereis
gave you, you will choose the one with the pcap.h substring at the end (without the pcap.h part).
Upvotes: 7
Reputation: 2430
Your library might be missing, install it and link it
yum install libpcap-devel
In your makefile add:
-L/usr/lib -lpcap
Upvotes: 16
Reputation: 69012
You'll have to specify the folder where the headers are installed, for example:
gcc -I/usr/include/pcap my_file.c -lpcap
Try locate pcap.h
to find the right directory to use with the -I
switch.
Upvotes: 3