当前位置: 技术问答>linux和unix
Ubuntu 下 ARP Sniffer 源码 编译出错
来源: 互联网 发布时间:2016-08-27
本文导语: 小弟最近开始学习Linux下编程 在研究某大虾给的关于 ARP Sniffer的源码的时候 遇到一个十分纠结的问题 大虾的源码在如下地址中 http://www.lslnet.com/linux/f/docs1/i03/big5120787.htm 按照他的要求 我先安装了 pcap和libnet 中...
小弟最近开始学习Linux下编程 在研究某大虾给的关于 ARP Sniffer的源码的时候 遇到一个十分纠结的问题
大虾的源码在如下地址中
http://www.lslnet.com/linux/f/docs1/i03/big5120787.htm
按照他的要求 我先安装了 pcap和libnet 中间遇到各种纠结 纠缠了一整天总算搞定
然后 编译代码 gcc -I/usr/local/include -L/usr/local/lib -o sniffer sniffer.c -lpcap -lnet
这时候 最蛋疼的事情出现了 出现了一大堆莫名其妙的错误 尤其第一个错误直指 libnet.h 这个头文件 我很郁闷 我刚装的libnet 怎么头文件里还有错误。。。
错误如下
sniffer.c:20:19: warning: extra tokens at end of #include directive
sniffer.c:21:20: warning: extra tokens at end of #include directive
sniffer.c:22:23: warning: extra tokens at end of #include directive
sniffer.c:23:18: warning: extra tokens at end of #include directive
sniffer.c:24:20: warning: extra tokens at end of #include directive
In file included from sniffer.c:24:
/usr/include/libnet.h:87:2: error: #error "byte order has not been specified, you'll
In file included from sniffer.c:24:
/usr/include/libnet.h:88: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘to’
/usr/include/libnet.h:88: error: stray ‘#’ in program
/usr/include/libnet.h:89: error: missing terminating " character
sniffer.c:187: error: expected ‘)’ before ‘*’ token
sniffer.c:226: error: expected ‘)’ before ‘*’ token
sniffer.c:237: error: expected ‘)’ before ‘*’ token
sniffer.c: In function ‘printdat’:
sniffer.c:292: error: expected expression before ‘;’ token
sniffer.c:321: error: expected expreror: e
下面还有很长 但是我首先纠结的就是再libnet.h里的错误到底是啥意思?...
然后后面的错误又是怎么回事呢? 我看到好像很多人都说用这段代码没问题啊? 难道源码有问题?
我用的 Ubuntu 10 gcc gnu m4 flex bison libnet 都反复更新过
实属无奈了 希望得到大家的帮助
大虾的源码在如下地址中
http://www.lslnet.com/linux/f/docs1/i03/big5120787.htm
按照他的要求 我先安装了 pcap和libnet 中间遇到各种纠结 纠缠了一整天总算搞定
然后 编译代码 gcc -I/usr/local/include -L/usr/local/lib -o sniffer sniffer.c -lpcap -lnet
这时候 最蛋疼的事情出现了 出现了一大堆莫名其妙的错误 尤其第一个错误直指 libnet.h 这个头文件 我很郁闷 我刚装的libnet 怎么头文件里还有错误。。。
错误如下
sniffer.c:20:19: warning: extra tokens at end of #include directive
sniffer.c:21:20: warning: extra tokens at end of #include directive
sniffer.c:22:23: warning: extra tokens at end of #include directive
sniffer.c:23:18: warning: extra tokens at end of #include directive
sniffer.c:24:20: warning: extra tokens at end of #include directive
In file included from sniffer.c:24:
/usr/include/libnet.h:87:2: error: #error "byte order has not been specified, you'll
In file included from sniffer.c:24:
/usr/include/libnet.h:88: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘to’
/usr/include/libnet.h:88: error: stray ‘#’ in program
/usr/include/libnet.h:89: error: missing terminating " character
sniffer.c:187: error: expected ‘)’ before ‘*’ token
sniffer.c:226: error: expected ‘)’ before ‘*’ token
sniffer.c:237: error: expected ‘)’ before ‘*’ token
sniffer.c: In function ‘printdat’:
sniffer.c:292: error: expected expression before ‘;’ token
sniffer.c:321: error: expected expreror: e
下面还有很长 但是我首先纠结的就是再libnet.h里的错误到底是啥意思?...
然后后面的错误又是怎么回事呢? 我看到好像很多人都说用这段代码没问题啊? 难道源码有问题?
我用的 Ubuntu 10 gcc gnu m4 flex bison libnet 都反复更新过
实属无奈了 希望得到大家的帮助
|
lz的提问不景气阿