简体   繁体   English

boost.asio和pfring冲突

[英]boost.asio and pfring conflict

I wrote a program witch use pfring and asio, 我写了一个使用pfring和asio的程序,

My program like: 我的程序像:

#include <boost/asio.hpp>
#include <pfring.h>

int main(void) {
    // ... 
    return 0;
}

I got error: 我收到错误消息:

In file included from /usr/local/include/pfring.h:46:0,
             from test.cpp:2:
/usr/include/linux/if.h:136:8: error: redefinition of 'struct ifmap'
/usr/include/net/if.h:112:8: error: previous definition of 'struct ifmap'
/usr/include/linux/if.h:170:8: error: redefinition of 'struct ifreq'
/usr/include/net/if.h:127:8: error: previous definition of 'struct ifreq'
/usr/include/linux/if.h:219:8: error: redefinition of 'struct ifconf'
/usr/include/net/if.h:177:8: error: previous definition of 'struct ifconf'

How can I resolve this problem? 我该如何解决这个问题?

This isn't a conflict between boost and pfringe. 这不是boost和pfringe之间的冲突。 The problem is explained here: 问题在这里解释:

/usr/include/linux/if.h:136:8: error: redefinition of 'struct ifmap'
/usr/include/net/if.h:112:8: error: previous definition of 'struct ifmap'

It appears that the problem is being caused by a collision within the Linux headers. 看来问题是由Linux标头内的冲突引起的。 First, check if you have the latest Linux kernel, Linux headers, and pfringe. 首先,检查您是否具有最新的Linux内核,Linux标头和pfringe。 If not, update them. 如果不是,请更新它们。 If that fails, check to see if you have any old headers lying around. 如果失败,请检查是否有旧的标头。 If so, remove them. 如果是这样,请将其删除。 In Ubuntu, this can be done from the Computer Janitor application. 在Ubuntu中,这可以通过Computer Janitor应用程序完成。 If all else fails, try uninstalling and reinstalling pfringe. 如果其他所有方法均失败,请尝试卸载并重新安装pfringe。 Make sure it's the appropriate version for your OS! 确保它是适合您的操作系统的版本!

I forgot a macro, add to CFLAGS -DHAVE_PCAP. 我忘记了一个宏,将其添加到CFLAGS -DHAVE_PCAP。 It's solved. 解决了 Thanks everyone 感谢大家

The linux headers are broken. linux标头已损坏。 On the latest ubuntu 11.10 release with the latest kernel with no old headers lying around, the following program fails to compile. 在最新的ubuntu 11.10发行版上,如果使用最新的内核且没有旧的头文件,则以下程序无法编译。 It is quite annoying when I need parts from both headers, like if_nametoindex() from net/if.h and ARPHRD_ETHER from linux/if_arp.h - So all I can do is copy/paste the definitions that I need into my source from the linux headers!! 当我需要两个标头中的部分时,这很烦人,例如net / if.h中的if_nametoindex()和linux / if_arp.h中的ARPHRD_ETHER-因此,我所能做的就是将需要的定义复制/粘贴到源文件中linux头文件!!

#include <linux/if.h>
#include <net/if.h>

int main()
{
}

Errors: 错误:

In file included from x.c:1:0:
/usr/include/linux/if.h:178:19: error: field ‘ifru_addr’ has incomplete type
/usr/include/linux/if.h:179:19: error: field ‘ifru_dstaddr’ has incomplete type
/usr/include/linux/if.h:180:19: error: field ‘ifru_broadaddr’ has incomplete type
/usr/include/linux/if.h:181:19: error: field ‘ifru_netmask’ has incomplete type
/usr/include/linux/if.h:182:20: error: field ‘ifru_hwaddr’ has incomplete type
In file included from x.c:2:0:
/usr/include/net/if.h:45:5: error: expected identifier before numeric constant
/usr/include/net/if.h:112:8: error: redefinition of ‘struct ifmap’
/usr/include/linux/if.h:136:8: note: originally defined here
/usr/include/net/if.h:127:8: error: redefinition of ‘struct ifreq’
/usr/include/linux/if.h:170:8: note: originally defined here
/usr/include/net/if.h:177:8: error: redefinition of ‘struct ifconf’
/usr/include/linux/if.h:219:8: note: originally defined here

Edit: It looks like this bug has been fixed in the linux kernel package 2.6.37-4.12 now: 编辑:看来此错误已在linux内核软件包2.6.37-4.12中修复:

https://bugs.launchpad.net/ubuntu/+source/eglibc/+bug/673073/comments/10 https://bugs.launchpad.net/ubuntu/+source/eglibc/+bug/673073/comments/10

But for some reason it doesn't work on my system which is linux 3.0 based. 但是由于某种原因,它在基于linux 3.0的系统上不起作用。 hmmm... 嗯...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM