Tuesday, December 28, 2021

[SOLVED] Problems finding pcap.h and linking

Issue

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!


Solution

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.



Answered By - mata