Linux系统Eclipse CDT引用动态库(第三方库)的解决方案及问题

1、PFring第三方库的编译和demo运行

PFring为第三方快速抓包库,具体的安装和例子使用方法见:http://blog.csdn.net/xuejiren/article/details/21529027,此地方不再累赘。

2、PFring在新建项目中的使用方案

2.1 编译和安装kernel和libpcap到/usr/local目录下

2.1.1 kernel的安装
 1)进入PF_Ring/kernel目录
 2)./configure --prefix=/usr/local/
  3)make
 4) make install
2.1.2 kernel的安装
 1)进入PF_Ring/userland/libpcap目录
 2)./configure --prefix=/usr/local/
3)make
 4) make install
2.1.3 查看/usr/local/lib和/usr/local/include里面是否有libpcap.a、libpcap.so、libpfring.a等等以及相应的头文件

2.2 新建一个c++ project工程,并配置

2.2.1 新建一个c++ project工程TestPFRing
2.2.2 拷贝alldevs.c里面的源码到TestPFRing.cpp
2.2.3 添加包含目录: 右击项目-> properties->GCC C++ Compiler->includes
2.2.4 添加第三方库: 右击项目-> properties-> GCC C++ Linker LIbraries ->Libraries

2.2.4 添加环境变量: 右击项目-> Run As->Run Confiturations->Environment  添加环境变量


2.3 存在的问题

问题1:packet direction direction; error: expected specifier-qualifier-list before ‘packet direction’

方案:将/usr/local/include/pf_ring.h用PF_RING/userland/lib/pf_ring.h代替

问题2:undefined reference to `pcap_findalldevs'

方案:动态库Libraries不仅要指明目录,而且要指明动态库名称,其中将libpcap.so变为pcap加入到Libraries中
                              

问题3:error while loading shared libraries

方案:参见http://blog.csdn.net/dumeifang/article/details/2963223,或者下面的内容

在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,将给你最实惠价格。

店名:小时代乐园

承诺:本店以诚信求生存,以质量求人员,货真价实,绝无欺骗行为。
简介:本店主要营销大品牌、安全有保障的商品,提供儿童益智娱乐品牌宝贝,让你全方位精心打扮,提升体验度和品味,让你买得开心,用得放心,穿得舒心,听得暖心。



  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值