Problems finding pcap.h and binding

I am working on Fedora 17 and I want to program using libpcap. The problem is that my computer does not find pcap.h, which is really wierd, since I installed libpcap and libpcap-devel. Also at my station are wirehark and snort, which I believe use this library. Therefore, when I compile my code with ...

#include <pcap.h> ... Code 

And use gcc my_file.c -lpcap, I get compiler errors that say ... I can not find pcap.h. What is strange is that I see the libpcap.so files in the / libraries / directory. I did..

yum install libpcap as well as yum install libpcap-devel

I do not know why Fedora does this to me.

Thanks for any help!

+6
source share
4 answers

You need to specify the folder in which the headers are installed, for example:

 gcc -I/usr/include/pcap my_file.c -lpcap 

Try locate pcap.h find the correct directory to use with the -I .

+2
source

Perhaps your library is missing, install it and connect to it.

 yum install libpcap-devel 

In your makefile add:

 -L/usr/lib -lpcap 
+10
source

Try

 ~$ whereis pcap 

Then, as they say mata p>

 gcc -lpcap -I{path} file.c 

where {path} is the path that whereis gave you, you will choose the one with the substring pcap.h at the end (without the pcap.h part).

+6
source

To execute a program in C ++:

for C ++ program

  g++ program_name.cpp -lpcap 
0
source

All Articles