安装packet-fu时无法安装pcaprub的问题求助
安装packet-fu时pcaprub编译失败的解决方向
已完成操作
已成功执行以下命令:
apt-get install ruby-dev apt-get install libpcap-dev
遇到的问题
执行gem install -r pcaprub时,出现原生扩展编译失败的错误,完整错误日志如下:
# gem install pcaprub Building native extensions. This could take a while... ERROR: Error installing pcaprub: ERROR: Failed to build gem native extension. current directory: /var/lib/gems/2.7.0/gems/pcaprub-0.13.1/ext/pcaprub_c /usr/bin/ruby2.7 -I /usr/lib/ruby/vendor_ruby -r ./siteconf20230625-212902-9pqf73.rb extconf.rb [*] Running checks for pcaprub_c code... platform is x86_64-linux-gnu checking for ruby/thread.h... *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/usr/bin/$(RUBY_BASE_NAME)2.7 --with-pcap-dir --without-pcap-dir --with-pcap-include --without-pcap-include=${pcap-dir}/include --with-pcap-lib --without-pcap-lib=${pcap-dir}/lib --with-ruby-dir --without-ruby-dir --with-ruby-include --without-ruby-include=${ruby-dir}/include --with-ruby-lib --without-ruby-lib=${ruby-dir}/lib /usr/lib/ruby/2.7.0/mkmf.rb:471:in `try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /usr/lib/ruby/2.7.0/mkmf.rb:613:in `try_cpp' from /usr/lib/ruby/2.7.0/mkmf.rb:1124:in `block in have_header' from /usr/lib/ruby/2.7.0/mkmf.rb:971:in `block in checking_for' from /usr/lib/ruby/2.7.0/mkmf.rb:361:in `block (2 levels) in postpone' from /usr/lib/ruby/2.7.0/mkmf.rb:331:in `open' from /usr/lib/ruby/2.7.0/mkmf.rb:361:in `block in postpone' from /usr/lib/ruby/2.7.0/mkmf.rb:331:in `open' from /usr/lib/ruby/2.7.0/mkmf.rb:357:in `postpone' from /usr/lib/ruby/2.7.0/mkmf.rb:970:in `checking_for' from /usr/lib/ruby/2.7.0/mkmf.rb:1123:in `have_header' from extconf.rb:82:in `<main>' To see why this extension failed to compile, please check the mkmf.log which can be found here: /var/lib/gems/2.7.0/extensions/x86_64-linux/2.7.0/pcaprub-0.13.1/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /var/lib/gems/2.7.0/gems/pcaprub-0.13.1 for inspection. Results logged to /var/lib/gems/2.7.0/extensions/x86_64-linux/2.7.0/pcaprub-0.13.1/gem_make.out
解决方向
安装基础编译工具:错误日志明确提示需要开发工具,执行以下命令:
apt-get install build-essential安装完整Ruby开发环境:ruby-dev可能依赖不全,尝试安装ruby-full确保头文件和依赖完整:
apt-get install ruby-full指定libpcap路径安装pcaprub:如果libpcap的路径未被自动识别,手动指定路径:
gem install pcaprub --with-pcap-include=/usr/include --with-pcap-lib=/usr/lib/x86_64-linux-gnu尝试兼容版本的pcaprub:pcaprub 0.13.1可能与Ruby 2.7存在兼容性问题,降级到0.12.4版本尝试:
gem install pcaprub -v 0.12.4查看详细编译日志:mkmf.log会记录具体失败原因,执行以下命令查看并补充对应依赖:
cat /var/lib/gems/2.7.0/extensions/x86_64-linux/2.7.0/pcaprub-0.13.1/mkmf.log直接安装packet-fu:无需单独安装pcaprub,packet-fu会自动处理依赖:
gem install packet-fu
内容的提问来源于stack exchange,提问作者Teererai Marange
相关产品推荐
相关产品推荐

