私は私のLinuxシステム上のpcapライブラリをインストールしますが、それを含めたとき、私はエラーがC PCAPライブラリ不明なタイプエラー
/usr/include/pcap/bpf.h:88:1: error: unknown type name ‘u_int’
/usr/include/pcap/bpf.h:108:2: error: unknown type name ‘u_int’
/usr/include/pcap/bpf.h:1260:2: error: unknown type name ‘u_short’
/usr/include/pcap/bpf.h:1261:2: error: unknown type name ‘u_char’
/usr/include/pcap/bpf.h:1262:2: error: unknown type name ‘u_char’
In file included from ../src/test.c:1:0:
/usr/include/pcap/pcap.h:125:2: error: unknown type name ‘u_short’
/usr/include/pcap/pcap.h:126:2: error: unknown type name ‘u_short’
/usr/include/pcap/pcap.h:171:2: error: unknown type name ‘u_int’
...
make: *** [src/test.o] Error 1
私は、プログラム中の
#include <pcap/pcap.h>
#include <sys/types.h>
#include <pcap-bpf.h>
を含め、私が何をしないのです取得?
いいえ私は単純に 'gcc -std = c99 test.c -o test'とコンパイルしていませんでした。 – wasp256
実際には、はい、あなたは* -std = c99を指定して、 。 GCCのmanページによれば、 '-std ='は '-ansi'と同じ効果を持ち、' -ansi'は '__STRICT_ANSI__'を定義します。 '-std = c99'は、' _ISOC99_SOURCE'と '__STRICT_ANSI__'の代わりに、またはその代わりに' _ISOC99_SOURCE'を定義します。 '-std = c99'は、コードが厳密なISO C99としてコンパイルされることを意味します。つまり、ISO C99にはない機能は使用できません。また、libpcapはISO C99にはありません。 C99機能を使用しようとしていて、デフォルトではサポートされていないので、 '-std = gnu99'を試してみてください。 –