我正在尝试编译这个名为 Pirni 的 C 程序,它最初是为 iPhone 制作的,我想在 linux Ubuntu 12.04 LTS 上运行它。它很短,(3 个 C 文件和 1 个头文件)。但我收到以下错误。我确实已经libpcap-dev
安装并且我确实包含-lpcap
了所以我不知道可能出了什么问题。
gcc -Wall -pthread -lpcap pirni.c threads.c sniffer.c -o pirni -lnet
pirni.c: In function ‘set_forwarding’:
pirni.c:31:2: warning: implicit declaration of function ‘sysctlbyname’ [-Wimplicit-function-declaration]
/tmp/cc3sf284.o: In function `set_forwarding':
pirni.c:(.text+0xfd): undefined reference to `sysctlbyname'
/tmp/ccvGjyMo.o: In function `processPacket':
sniffer.c:(.text+0x1b): undefined reference to `pcap_dump'
/tmp/ccvGjyMo.o: In function `initSniffer':
sniffer.c:(.text+0xfa): undefined reference to `pcap_open_live'
sniffer.c:(.text+0x15a): undefined reference to `pcap_lookupnet'
sniffer.c:(.text+0x1af): undefined reference to `pcap_compile'
sniffer.c:(.text+0x1dd): undefined reference to `pcap_setfilter'
sniffer.c:(.text+0x222): undefined reference to `pcap_dump_open'
sniffer.c:(.text+0x27c): undefined reference to `pcap_loop'
collect2: ld returned 1 exit status
make: *** [main] Error 1