使用/usr/include/net/if.h时编译错误

时间:2011-10-26 06:23:25

标签: macos compilation network-programming libpcap network-security

我正在尝试在Mac Lion上编译网络嗅探器的现有源代码。我安装了libpcap。源包含一个头文件/usr/include/net/if.h,它会抛出编译错误,如下所示。

Floyd:~ Shastry$ gcc -o arplisten arplisten.c -lpcap
In file included from arplisten.c:4:
/usr/include/net/if.h:265: error: field ‘ifru_addr’ has incomplete type
/usr/include/net/if.h:266: error: field ‘ifru_dstaddr’ has incomplete type
/usr/include/net/if.h:267: error: field ‘ifru_broadaddr’ has incomplete type
/usr/include/net/if.h:308: error: field ‘ifra_addr’ has incomplete type
/usr/include/net/if.h:309: error: field ‘ifra_broadaddr’ has incomplete type
/usr/include/net/if.h:310: error: field ‘ifra_mask’ has incomplete type
/usr/include/net/if.h:393: error: field ‘addr’ has incomplete type
/usr/include/net/if.h:394: error: field ‘dstaddr’ has incomplete type
arplisten.c:6:24: error: netinet/if.h: No such file or directory
arplisten.c: In function ‘main’:
arplisten.c:139: warning: incompatible implicit declaration of built-in function ‘strlen’
Floyd:~ Shastry$ 

我做了很多谷歌搜索,徒劳无功。有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:3)

看起来它是包含文件的顺序。请参阅我通过谷歌找到的page