Para o Ubuntu 12.04, 12.10, 13.10, 14.04 e em diante, abra o terminal e digite:
sudo apt-get install libpcap0.8-dev
Eu tenho uma atribuição de programação onde eu preciso usar o pcap lib.
#define _BSD_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pcap.h> // <-- missing include
#include <netinet/ip.h>
#include <netinet/tcp.h>
void logpacket( unsigned char* payload, struct ip* ipheader, struct tcphdr* tcpheader )
{
//...
}
int main(int argc, char* argv[] )
{
//...
}
Como posso obter os arquivos da biblioteca que preciso para compilar este programa?
Para o Ubuntu 12.04, 12.10, 13.10, 14.04 e em diante, abra o terminal e digite:
sudo apt-get install libpcap0.8-dev
Você pode instalá-los. Tente com o comando
sudo apt-get install pcap*
Eu acho que você precisa dev lib. Na minha lista de pc é:
xxxxx@xxxxx ~ $ sudo apt-get install pcap*
[sudo] password for darkstar:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'libchipcard-dev' for regex 'pcap*'
Note, selecting 'libchipcard-pcsc-card-perl' for regex 'pcap*'
Note, selecting 'libpcapnav0' for regex 'pcap*'
Note, selecting 'python-ipcalc' for regex 'pcap*'
Note, selecting 'libchipcard-tools' for regex 'pcap*'
Note, selecting 'sipcalc' for regex 'pcap*'
Note, selecting 'pcal' for regex 'pcap*'
Note, selecting 'pcaputils' for regex 'pcap*'
Note, selecting 'libdate-pcalc-perl' for regex 'pcap*'
Note, selecting 'libpcap0.7-dev' for regex 'pcap*'
Note, selecting 'lua5.1-coxpcall' for regex 'pcap*'
Note, selecting 'libmlpcap-ocaml-dev' for regex 'pcap*'
Note, selecting 'libmlpcap-ocaml' for regex 'pcap*'
Note, selecting 'libpcap0.8' for regex 'pcap*'
Note, selecting 'libmlpcap-ocaml-7zxa8' for regex 'pcap*'
Note, selecting 'python-pcapy' for regex 'pcap*'
Note, selecting 'libpcap0.8-dbg' for regex 'pcap*'
Note, selecting 'libmlpcap-ocaml-dev-7zxa8' for regex 'pcap*'
Note, selecting 'pcalendar' for regex 'pcap*'
Note, selecting 'libghc-pcap-prof' for regex 'pcap*'
Note, selecting 'python2.7-libpcap' for regex 'pcap*'
Note, selecting 'libpcap0.8-dev' for regex 'pcap*'
Note, selecting 'libchipcard6' for regex 'pcap*'
Note, selecting 'ulogd-pcap' for regex 'pcap*'
Note, selecting 'apcalc-common' for regex 'pcap*'
Note, selecting 'libghc-pcap-prof-0.4.5.2-a3d5c' for regex 'pcap*'
Note, selecting 'libghc-pcap-dev-0.4.5.2-a3d5c' for regex 'pcap*'
Note, selecting 'liblua5.1-coxpcall0' for regex 'pcap*'
Note, selecting 'apcalc-dev' for regex 'pcap*'
Note, selecting 'libghc-pcap-dev' for regex 'pcap*'
Note, selecting 'libpcapnav0-dev' for regex 'pcap*'
Note, selecting 'libchipcard-data' for regex 'pcap*'
Note, selecting 'python2.7-pypcap' for regex 'pcap*'
Note, selecting 'apcalc' for regex 'pcap*'
Note, selecting 'libnet-pcap-perl' for regex 'pcap*'
Note, selecting 'udpcast' for regex 'pcap*'
Note, selecting 'libpoe-component-pcap-perl' for regex 'pcap*'
Note, selecting 'pcapfix' for regex 'pcap*'
Note, selecting 'libchipcard-libgwenhywfar60-plugins' for regex 'pcap*'
Note, selecting 'lua-coxpcall' for regex 'pcap*'
Note, selecting 'python-pypcap' for regex 'pcap*'
Note, selecting 'libpcap-dev' for regex 'pcap*'
Note, selecting 'libghc-pcap-doc' for regex 'pcap*'
Note, selecting 'python-libpcap' for regex 'pcap*'
Note, selecting 'python2.7-pcapy' for regex 'pcap*'
Note, selecting 'ulogd2-pcap' for regex 'pcap*'
Note, selecting 'ipcalc' for regex 'pcap*'
Note, selecting 'libchipcardd0' for regex 'pcap*'
Note, selecting 'dispcalgui' for regex 'pcap*'
Note, selecting 'python2.7-ipcalc' for regex 'pcap*'
Note, selecting 'libghc-pcap-dev' instead of 'libghc-pcap-dev-0.4.5.2-a3d5c'
Note, selecting 'libghc-pcap-prof' instead of 'libghc-pcap-prof-0.4.5.2-a3d5c'
Note, selecting 'libmlpcap-ocaml' instead of 'libmlpcap-ocaml-7zxa8'
Note, selecting 'libmlpcap-ocaml-dev' instead of 'libmlpcap-ocaml-dev-7zxa8'
Note, selecting 'libpcsc-perl' instead of 'libchipcard-pcsc-card-perl'
Note, selecting 'lua-coxpcall' instead of 'lua5.1-coxpcall'
Note, selecting 'python-ipcalc' instead of 'python2.7-ipcalc'
Note, selecting 'python-libpcap' instead of 'python2.7-libpcap'
Note, selecting 'python-pcapy' instead of 'python2.7-pcapy'
Note, selecting 'python-pypcap' instead of 'python2.7-pypcap'
Tente adicionar um por um com dependência
Em "Trusty Tahr" o seguinte foi trabalhado para mim:
λ ~ cat /etc/issue Ubuntu 14.04.2 LTS \n \l λ ~ sudo apt-get install libpcap-dev