47

anyone know how to fix the problem regarding header file in ubuntu 10.10. I am executing a sniffing program which makes use of this header file. My system shows libcap package is installed. Still, on compiling the code, an error is coming which reads:

fatal error: pcap.h: No such file or directory compilation terminated.

Please help me out.

Thanks all:)

nwprogrammer
  • 471
  • 1
  • 4
  • 3

6 Answers6

67

The system won't let me correct Eric Fossum's comment, because I lack reputation. There is a typo ("libcap" vs. "libpcap") and his suggested command should read the following:

sudo apt-get install libpcap-dev
famzah
  • 1,462
  • 18
  • 21
52
sudo apt-get install libpcap0.8-dev
Dhaivat Pandya
  • 6,499
  • 4
  • 29
  • 43
  • 15
    or try `sudo apt-get install libcap-dev` to better suite your OS's update system – Eric Fossum Nov 21 '11 at 16:48
  • 4
    Actually, the original answer is 'correct'. Out the box you may be wanting to install something and just get it to work. If you run `sudo apt-get install libpcap0.8-dev` then you are good to go, if you don't get the 0.8 bit in there then you'll still be hunting around for where the pcap.h file is and trying to put it into a path somehow. – ʍǝɥʇɐɯ Feb 14 '12 at 10:51
  • 3
    @EricFossum just for the record - you probably ment `libpcap-dev`, you have a typo. So I'm leaving this comment to prevent others from dumb cccv like I did – Piotr Zierhoffer Apr 01 '17 at 12:03
4

If you are using yum, then

sudo yum install install libpcap-devel
jerryleooo
  • 843
  • 10
  • 16
3

If you're using linuxbrew, you can just brew install libpcap. In my case I was trying to install nethogs and it failed with this error.

Fábio Santos
  • 3,899
  • 1
  • 26
  • 31
3

You don't have the pcap.h file in your include path. You need to add the location of pcap.h to your include path when compiling:

-I/path/to/pcap.h

Tony Lukasavage
  • 1,937
  • 1
  • 14
  • 26
1

First install libpcap:

sudo apt-get install libpcap0.8-dev

then create its shortcut for header file:

ln -s /usr/include/pcap/bpf.h /usr/include/net/bpf.h
Eyni Kave
  • 1,113
  • 13
  • 23