J'ai une tâche de programmation où j'ai besoin d'utiliser la librairie pcap.
#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[] )
{
//...
}
Comment puis-je obtenir les fichiers de bibliothèque dont j'ai besoin pour compiler ce programme?
Pour Ubuntu 12.04, 12.10, 13.10, 14.04 et ultérieurs, ouvrez le terminal et tapez:
Sudo apt-get install libpcap0.8-dev
Sur "Trusty Tahr", je travaille comme suit:
λ ~ cat /etc/issue[.____. Garden Ubuntu 14.04.2 LTS\n\l λ ~ Sudo apt-get installer libpcap-dev
Vous pouvez les installer. Essayer avec commande
Sudo apt-get install pcap*
Je suppose que vous avez besoin de dev lib. Sur ma liste de PC est:
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'
Essayez d'ajouter un à un avec dépendance