CentOS安装libpcap
1.安装GCC:
yum -y install gcc-c++
2.安装flex:
yum -y install flex
没有flex,直接安装libpcap会提⽰"Your operating system's lex is insufficient to compile libpcap"错误;
3.安ison
yum -y install bison
前⾯安装的是flex,就需要搭配bison,如不会提⽰"don't have both flex and bison;reverting to lex/yacc"错误;解压软件包:tar zxf libpcap-1.0.
进⼊解压后的⽬录,输⼊命令⾏:
命令如下:
./configure
make
make install
5.简单的例⼦测试⼀下libpcap:
//device.c
#include <stdio.h>
#include <pcap.h>
int main(int argc,char *argv[]){
char *dev, errbuf[PCAP_ERRBUF_SIZE];
dev=pcap_lookupdev(errbuf);
if(dev==NULL){
fprintf(stderr,"couldn't find default device: %s\n",errbuf);
return(2);
}
printf("Device: %s\n",dev);
return(0);
}
编译指令:gcc -o device device.c -lpcap
备注:编译时要使⽤libpcap的参数-lpcap,否则会提⽰“pcap_lookupdev 未定义的引⽤”的错误;
运⾏指令:./device
运⾏遇到错误解决办法:
//-----------------------------------------------------------
/
/AUTHOR:lanyang123456
//DATE:2011-11-10
//-----------------------------------------------------------
Linux系统下,运⾏sniff程序需要libpcap库。
点击DOWNLOADS
下载后
(1)解压
(2)进⼊解压后⽂件⽬录, ./configure
(3)make install
默认安装⽬录/usr/local/lib
编译sniff程序通过,运⾏sniff程序时,出现如下错误:
.
/sn: error while loadingshared libraries: libpcap.so.1: cannot open shared object file: No such file ordirectory
由于libpcap已经安装,所以是程序⽆法到库所在的位置的原因。
解决办法:
将libpcap.so.1所在⽬录添加到⽂件/etc/f中,
打开f⽂件,然后添加⼀⾏/usr/local/lib:
f.d/*.conf //原来的内容
/usr/local/lib
然后保存,再终端下执⾏ ldconfig。
再运⾏sniff程序,OK。
有时⽤tar解压⽂件.错误如下:
gzip: stdin: unexpectedend of file tar: Unexpected EOF in archive tar: Unexpected EOF in archive tar:Error is not recoverable: exiting now 原因:
⽂件被破坏,重新下载。
libnet.so.1: cannot open shared object file: No such file or directory
安装了libnet
./configure
make
make install
程序编译正确,但是执⾏的时候出现如下问题
libnet.so.1: cannot open shared object file: No such file or directory
这种问题经常出现,原因是程序执⾏时寻的是/usr/lib下的库,⽽libnet默认安装到了/usr/local/lib
解决⽅法:
1.将所有⽂件/usr/local/lib的所有⽂件拷贝到/usr/lib下,应该可以,没有尝试。
2.vim /etc/f.d/ld.f
添加 /usr/local/lib
退出保存
ldconfig
然后在执⾏程序。ok。
参考www.2cto/os/201306/222628.html
cannot open shared object file: No such file or directory解决
./move_db: error while loading shared libraries: libclient.so.15: cannot
open shared object file: No such file or directory
第⼀步:确认有哪些Lib⽆法Load
>ldd move_dbcentos vim命令
linux-gate.so.1 => (0x0089c000)
libmysqlclient.so.15 => not found
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00cfa000)
libm.so.6 => /lib/libm.so.6 (0x00804000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x009f8000)
libc.so.6 => /lib/libc.so.6 (0x0069e000)
/lib/ld-linux.so.2 (0x0067b000)
第⼆步:要确认动态库的地址,把动态库的路径放到/etc/f中
建议:在/etc/f.d/上新建动态库相应的⽂件配置⽂件*.conf,
在该⽂件中填上该动态库的绝对路径
此例:
vim /etc/f.f
/usr/local/mysql/lib
第三步:运⾏ldconfig  重建/etc/ld.so.cache

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。