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.安装bison
yum -y install bison
前面安装的是flex,就需要搭配bison,如不会提示"don't have both flex and bison;reverting to lex/yacc"错误;
4.安装 libpcap
下载地址:http://www.tcpdump.org/
下载版本:wget -c http://www.tcpdump.org/release/libpcap-1.5.3.tar.gz
解压软件包:tar zxf libpcap-1.0.0.tar.gz
进入解压后的目录,输入命令行:
命令如下:
./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
转载:http://www.tcpdump.org/release/libpcap-1.5.3.tar.gz
http://blog.sina.com.cn/s/blog_6f289b0e01014jst.html
运行遇到错误解决办法:
error while loading shared libraries: libpcap.so.1: cannot open shared object file: No such file or
//-----------------------------------------------------------
//AUTHOR:lanyang123456
//DATE:2011-11-10
//-----------------------------------------------------------
Linux系统下,运行sniff程序需要libpcap库。
首先下载安装该库,下载地址: http://www.tcpdump.org/
点击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/ld.so.conf中,
打开ld.so.conf文件,然后添加一行/usr/local/lib:
includeld.so.conf.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
原因:
文件被破坏,重新下载。
转载:http://blog.csdn.net/lanyang123456/article/details/6956093
libnet.so.1: cannot open shared object file: No such file or directory
解决方法:
CentOS安装libpcap的更多相关文章
- Centos安装流量监控工具iftop笔记
Centos安装流量监控工具iftop笔记 一.概述 iftop可以用来监控网卡的实时流量(可以指定网段).反向解析IP.显示端口信息等,详细的将会在后面的使用参数中说明.官方网站:http://ww ...
- CentOS安装gitlab,gerrit,jenkins并配置ci流程
CentOS安装gitlab,gerrit,jenkins并配置ci流程 By Wenbin juandx@163.com 2016/4/9 这是我参考了网上很多的文档,配置了这三个软件在一个机器上, ...
- 【推荐】CentOS安装Subversion-1.8.11+HTTP协议支持配置
注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. 我们需要搭建一个自己的SVN服务器. 此外,搭建好的SVN服务器除了需要支持svn协议外,最好还需要支持HTTP协议和HTTPS协 ...
- 【推荐】CentOS安装PHP-5.6.4+扩展安装+安全配置+性能配置
注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. #准备工作# 前段时间PHP官方发布了一个重要的安全升级公告,修复了两个unserialize函数的严重漏洞,目前受影响的版本有: ...
- CentOS安装Apache-2.4.10+安全配置
注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. #准备工作# 在安装Nginx之前,请确保已经使用yum安装了各基础组件,并且配置了www用户和用户组,具体见<CentOS ...
- CentOS安装Nginx-1.6.2+安全配置
注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. #准备工作# 在安装Nginx之前,请确保已经使用yum安装了pcre等基础组件,具体见<CentOS安装LNMP环境的基础 ...
- CentOS安装MySQL-5.6.10+安全配置
注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. #准备工作# 在安装MySQL之前,请确保已经使用yum安装了各类基础组件,具体见<CentOS安装LNMP环境的基础组件& ...
- 转: CentOS 安装 SVN1.8 客户端
from: http://blog.csdn.net/clementad/article/details/46898091 CentOS 安装SVN客户端 标签: subversionrpmcent ...
- CentOS安装gitLab服务器
首先利用gitlab-install-el6.sh安装,比较简单: (出处:http://www.linuxidc.com/Linux/2013-06/85754.htm) 1:如果有条件,提供一台全 ...
随机推荐
- VIM标记 mark 详解
转载:http://blog.163.com/lgh_2002/blog/static/44017526201081154512135/ 我的vim配置:http://pan.baidu.com/s/ ...
- df 和 du 命令详解
df命令详细用法 a:显示全部的档案系统和各分割区的磁盘使用情形 i:显示i -nodes的使用量 k:大小用k来表示 (默认值) t:显示某一个档案系统的所有分割区磁盘使用量 x:显示不是某一个档案 ...
- Window Pains
http://poj.org/problem?id=2585 Window Pains Time Limit: 1000MS Memory Limit: 65536K Total Submissi ...
- Last non-zero Digit in N!
Problem Description The expression N!, read as "N factorial," denotes the product of the f ...
- Old Calculator
描述 szhhck have an old calculator bought 5 years ago.he find the old machine can just calculate expre ...
- SimpleAliasRegistry implements AliasRegistry
Spring - 4.2.3 // name,alias存储容器 ConcurrentHashMap <alias,name>private final Map<String, St ...
- ASP.NET MVC 下载列表
在ASP.NET WebForm里要想网站某个文件夹的文件列出来供用户下载似乎很简单,WebForm帮你做了很多事,只需要在Html文件里写: <a href="~/download/ ...
- 移动互联网(APP)产品设计的经验分享【转】
随着移动互联网的发展,越来越多的Web产品开始布局移动端,因此最近经常碰到PM们在交流讨论移动APP产品的设计.我从事移动互联网已经有一年多了,通过不断的学习和实践也积累了一些心得,今天整理并分享一下 ...
- 编写一个单独的Web Service for Delphi
早段时间看了一篇好文章,对其整理成以下几步 1新建一个SOAP Server Application,在提示输入接口时输入MyHello,把所有文件保存在一个叫Ser的目录下,其中一个包含TWebMo ...
- POJ 3069 Saruman's Army(贪心)
Saruman's Army Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Sub ...