2012-01-14 56 views
2

我寫了一個程序女巫使用pfring和ASIO,Boost.Asio的和pfring衝突

我的程序,如:

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

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

我得到錯誤:

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' 

我怎樣才能解決這個問題?

回答

1

這不是激勵和pfringe之間的衝突。問題解釋如下:

/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' 

看來問題是由Linux頭文件中的衝突引起的。首先,檢查你是否擁有最新的Linux內核,Linux頭文件和pfringe。如果沒有,更新它們。如果失敗了,請檢查是否有任何舊標題躺在附近。如果是這樣,請刪除它們。在Ubuntu中,這可以通過Computer Janitor應用程序完成。如果一切都失敗,請嘗試卸載並重新安裝pfringe。確保它是適合您操作系統的適當版本!

0

linux標頭已損壞。在最新的ubuntu 11.10發行版中,最新的內核沒有舊的頭文件,下面的程序無法編譯。當我需要兩個頭文件的部分時,這非常煩人,例如net/if.h中的if_nametoindex()和linux/if_arp.h中的ARPHRD_ETHER - 所以我所能做的就是將需要的定義複製/粘貼到我的源代碼中Linux標題!

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

int main() 
{ 
} 

錯誤:

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 

編輯:它看起來像這個bug已經被固定在Linux內核包2.6.37-4.12現在:

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

但對於一些因爲它不適用於我的系統,這是基於Linux 3.0的。嗯...

0

我忘了一個宏,添加到CFLAGS -DHAVE_PCAP。它解決了。謝謝大家