centos7安装libpcaplibnids

📅 2026/7/28 17:49:36
centos7安装libpcaplibnids
说明直接用yum安装的libpcap会在libnids安装的时候检查有问题所以需要下载安装包来安装1. 安装libpcap① 下载软件包libpcap-1.0.0.tar.gz下载地址http://www.tcpdump.org/release/libpcap-1.0.0.tar.gz② 解压软件包tar zxf libpcap-1.0.0.tar.gz③ 进入解压后的目录输入命令行./configure报错configure: error: no acceptable C compiler found in $PATHSee config.log for more details.解决安装gcc sudo yum install gcc继续./configure报错configure: error: Your operating systems lex is insufficient to compilelibpcap. flex is a lex replacement that has many advantages, includingbeing able to compile libpcap. For more information, seehttp://www.gnu.org/software/flex/flex.html .解决安装flexsudo yum install flex继续./configuremake报错make: yacc命令未找到make: *** [grammar.c] 错误 127解决 CentOS下是用flex和bison来分别代替lex和yacc的安装bisonsudo yum install bison继续./configuremakesudo make install如果没有事先安装flex和bison而是像我描述的这样遇到问题才装请先清理及卸载。输入命令行make cleanmake uninstall再重新来过否则会遇到libnids中的安装错误。2. 安装libnids① 下载软件包libnids-1.24.tar.gz下载地址https://sourceforge.net/projects/libnids/files/libnids/1.24/libnids-1.24.tar.gz/download② 解压软件包tar zxf libnids-1.24.tar.gz③ 进入解压后的目录输入命令行./configure --disable-libglib --disable-libnetmakesudo make install④ 进入libnids-1.24/samples运行make将printall.c编译为printall表示之后本机中所有与外界的TCP连接的数据包内容都会被打印在终端上。报错grammar.c:(.text0x44e): undefined reference to pcap_lexcollect2: ld 返回 1make: *** [overflows] 错误 1解决与libpcap的安装有关系所以完全卸载libnids和libpcap重新安装。继续make报错“警告隐式声明与内建函数‘exit’不兼容”之类的解决请按如下说明在相应的C文件中添加头文件警告 隐式声明与内建函数‘exit’不兼容 添加 #include与str相关的警告隐式声明与内建函数‘strlen’不兼容 添加 #include继续make