1、PFring第三方库的编译和demo运行
PFring为第三方快速抓包库,具体的安装和例子使用方法见:http://blog.csdn.net/xuejiren/article/details/21529027,此地方不再累赘。
2、PFring在新建项目中的使用方案
2.1 编译和安装kernel和libpcap到/usr/local目录下
2.2 新建一个c++ project工程,并配置
2.3 存在的问题
问题1:packet direction direction; error: expected specifier-qualifier-list before ‘packet direction’
问题2:undefined reference to `pcap_findalldevs'
问题3:error while loading shared libraries
在linux下运行程序时,发现了error while loading shared libraries这种错误,一时间不知道解决办法,在网上搜索,终于解决了:
./tests: error while loading shared libraries: xxx.so.0:cannot open shared object file: No such file or directory
出现这类错误表示,系统不知道xxx.so放在哪个目录下,这时候就要在/etc/ld.so.conf中加入xxx.so所在的目录。
一般而言,有很多的so会存放在/usr/local/lib这个目录底下,去这个目录底下找,果然发现自己所需要的.so文件。
所以,在/etc/ld.so.conf中加入/usr/local/lib这一行,保存之后,再运行:/sbin/ldconfig更新一下配置即可。
问题4:找不到函数库
Invoking: GCC C++ Linker
g++ -L/home/renxueji/PF_RING/userland/libpcap-1.1.1-ring -L/home/renxueji/PF_RING/userland/c++ -o "ReceiverBasedPFRing" ./src/ReceiverBasedPFRing.o ./src/TestPFRing.o -llog4cplus -lpfring -lpcap
/usr/local/lib/libpfring.so: undefined reference to `numa_parse_nodestring'
/usr/local/lib/libpfring.so: undefined reference to `numa_node_of_cpu'
/usr/local/lib/libpfring.so: undefined reference to `numa_available'
/usr/local/lib/libpfring.so: undefined reference to `numa_bind'
collect2: ld returned 1 exit status
make: *** [ReceiverBasedPFRing] Error 1
方案:在库函数中添加muma动态库
广告阶段:
本人开了淘宝店,欢迎你惠顾,价格优惠,购买是说明来于csdn,将给你最实惠价格。
店名:小时代乐园
承诺:本店以诚信求生存,以质量求人员,货真价实,绝无欺骗行为。简介:本店主要营销大品牌、安全有保障的商品,提供儿童益智娱乐品牌宝贝,让你全方位精心打扮,提升体验度和品味,让你买得开心,用得放心,穿得舒心,听得暖心。