web-dev-qa-db-ja.com

Ubuntuでpcap libを取得するにはどうすればよいですか?

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[] )
{
    //...
}

このプログラムをコンパイルするために必要なライブラリファイルを取得するにはどうすればよいですか?

3
John

Ubuntu 12.04、12.10、13.10、14.04以降では、ターミナルを開いて次のように入力します。

Sudo apt-get install libpcap0.8-dev  
8
karel

「Trusty Tahr」では、以下が私のために働いています:

λ〜cat /etc/issue
Ubuntu 14.04.2 LTS\n\l 
λ〜Sudo apt-get install libpcap-dev 
2
micrub

それらをインストールできます。コマンドで試す

Sudo apt-get install pcap*

Dev libが必要だと思います。私の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'

依存関係を1つずつ追加してみてください

2
2707974