Linux系统Eclipse CDT引用动态库(第三方库)的解决方案及有关问题
1、PFring第三方库的编译和demo运行
PFring为第三方快速抓包库,具体的安装和例子使用方法见:http://blog.****.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动态库