无法在 Linux 上使用 cpan/cpanm 安装 Net::Pcap

如何解决无法在 Linux 上使用 cpan/cpanm 安装 Net::Pcap

我正在尝试安装模块 Net::Pcap。这是我所做的:

[nick@void ~]$ cpanm Net::Pcap
--> Working on Net::Pcap
Fetching http://www.cpan.org/authors/id/S/SA/SAPER/Net-Pcap-0.18.tar.gz ... OK
Configuring Net-Pcap-0.18 ... OK
Building and testing Net-Pcap-0.18 ... FAIL
! Installing Net::Pcap failed. See /home/nick/.cpanm/work/1612889779.12603/build.log for details. Retry with --force to force install it. 

这是 build.log 文件:

[nick@void ~]$ cat /home/nick/.cpanm/work/1612889779.12603/build.log 
cpanm (App::cpanminus) 1.7044 on perl 5.032001 built for x86_64-linux
Work directory is /home/nick/.cpanm/work/1612889779.12603
You have make /usr/bin/make
You have /usr/bin/curl
You have /usr/bin/tar: tar (GNU tar) 1.32
Copyright (C) 2019 Free Software Foundation,Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY,to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
You have /usr/bin/unzip
Searching Net::Pcap () on cpanmetadb ...
--> Working on Net::Pcap
Fetching http://www.cpan.org/authors/id/S/SA/SAPER/Net-Pcap-0.18.tar.gz
-> OK
Unpacking Net-Pcap-0.18.tar.gz
Entering Net-Pcap-0.18
Checking configure dependencies from META.json
Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (7.44)
Configuring Net-Pcap-0.18
Running Makefile.PL
looking for -lpcap... yes
checking for pcap_lib_version() in -lpcap... yes
detecting available functions... ok
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Net::Pcap
Writing MYMETA.yml and MYMETA.json
-> OK
Checking dependencies from MYMETA.json ...
Checking if you have ExtUtils::MakeMaker 0 ... Yes (7.44)
Checking if you have Test::More 0.45 ... Yes (1.302175)
Checking if you have Socket 0 ... Yes (2.029)
Checking if you have XSLoader 0 ... Yes (0.30)
Checking if you have Carp 0 ... Yes (1.50)
Checking if you have Sys::Hostname 0 ... Yes (1.23)
Building and testing Net-Pcap-0.18
cp Pcap.pm blib/lib/Net/Pcap.pm
Running Mkbootstrap for Pcap ()
chmod 644 "Pcap.bs"
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Pcap.bs blib/arch/auto/Net/Pcap/Pcap.bs 644
"/usr/bin/perl" "/usr/share/perl5/core_perl/ExtUtils/xsubpp"  -typemap '/usr/share/perl5/core_perl/ExtUtils/typemap' -typemap '/home/nick/.cpanm/work/1612889779.12603/Net-Pcap-0.18/typemap'  Pcap.xs > Pcap.xsc
mv Pcap.xsc Pcap.c
cc -c   -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -g -D_FILE_OFFSET_BITS=64 -DLARGE_FILE_SUPPORT64 -Wall -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -g -D_FILE_OFFSET_BITS=64 -DLARGE_FILE_SUPPORT64   -DVERSION=\"0.18\" -DXS_VERSION=\"0.18\" -fPIC "-I/usr/lib/perl5/core_perl/CORE"  -DHAVE_BLANK -DHAVE_PCAP_LIB_VERSION -DHAVE_PCAP_BREAKLOOP -DHAVE_PCAP_COMPILE_NOPCAP -DHAVE_PCAP_DATALINK_NAME_TO_VAL -DHAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION -DHAVE_PCAP_DATALINK_VAL_TO_NAME -DHAVE_PCAP_DUMP_FILE -DHAVE_PCAP_DUMP_FLUSH -DHAVE_PCAP_FINDALLDEVS -DHAVE_PCAP_GETNONBLOCK -DHAVE_PCAP_GET_SELECTABLE_FD -DHAVE_PCAP_LIB_VERSION -DHAVE_PCAP_NEXT_EX -DHAVE_PCAP_OFFLINE_FILTER -DHAVE_PCAP_OPEN_DEAD -DHAVE_PCAP_SENDPACKET -DHAVE_PCAP_SETNONBLOCK -DHAVE_PCAP_SET_DATALINK Pcap.c
In file included from Pcap.xs:43:
stubs.inc:187:2: warning: #warning "the function pcap_list_datalinks() is not available" [-Wcpp]
  187 | #warning "the function pcap_list_datalinks() is not available"
      |  ^~~~~~~
stubs.inc:322:2: warning: #warning "the function pcap_createsrcstr() is not available" [-Wcpp]
  322 | #warning "the function pcap_createsrcstr() is not available"
      |  ^~~~~~~
stubs.inc:337:2: warning: #warning "the function pcap_parsesrcstr() is not available" [-Wcpp]
  337 | #warning "the function pcap_parsesrcstr() is not available"
      |  ^~~~~~~
stubs.inc:352:2: warning: #warning "the function pcap_open() is not available" [-Wcpp]
  352 | #warning "the function pcap_open() is not available"
      |  ^~~~~~~
stubs.inc:357:8: error: redefinition of 'struct pcap_rmtauth'
  357 | struct pcap_rmtauth {
      |        ^~~~~~~~~~~~
In file included from /usr/include/pcap.h:43,from Pcap.xs:32:
/usr/include/pcap/pcap.h:1036:8: note: originally defined here
 1036 | struct pcap_rmtauth
      |        ^~~~~~~~~~~~
In file included from Pcap.xs:43:
stubs.inc:363:10: error: conflicting types for 'pcap_open'
  363 | pcap_t * pcap_open(const char *source,int snaplen,int flags,int read_timeout,struct pcap_rmtauth *auth,char *err);
      |          ^~~~~~~~~
In file included from /usr/include/pcap.h:43,from Pcap.xs:32:
/usr/include/pcap/pcap.h:1084:18: note: previous declaration of 'pcap_open' was here
 1084 | PCAP_API pcap_t *pcap_open(const char *source,|                  ^~~~~~~~~
In file included from Pcap.xs:43:
stubs.inc:364:10: error: conflicting types for 'pcap_open'
  364 | pcap_t * pcap_open(const char *source,char *err) {
      |          ^~~~~~~~~
In file included from /usr/include/pcap.h:43,|                  ^~~~~~~~~
In file included from Pcap.xs:43:
stubs.inc:373:2: warning: #warning "the function pcap_setbuff() is not available" [-Wcpp]
  373 | #warning "the function pcap_setbuff() is not available"
      |  ^~~~~~~
stubs.inc:388:2: warning: #warning "the function pcap_setuserbuffer() is not available" [-Wcpp]
  388 | #warning "the function pcap_setuserbuffer() is not available"
      |  ^~~~~~~
stubs.inc:403:2: warning: #warning "the function pcap_setmode() is not available" [-Wcpp]
  403 | #warning "the function pcap_setmode() is not available"
      |  ^~~~~~~
stubs.inc:418:2: warning: #warning "the function pcap_setmintocopy() is not available" [-Wcpp]
  418 | #warning "the function pcap_setmintocopy() is not available"
      |  ^~~~~~~
stubs.inc:433:2: warning: #warning "the function pcap_sendqueue_alloc() is not available" [-Wcpp]
  433 | #warning "the function pcap_sendqueue_alloc() is not available"
      |  ^~~~~~~
stubs.inc:455:2: warning: #warning "the function pcap_sendqueue_destroy() is not available" [-Wcpp]
  455 | #warning "the function pcap_sendqueue_destroy() is not available"
      |  ^~~~~~~
stubs.inc:469:2: warning: #warning "the function pcap_sendqueue_queue() is not available" [-Wcpp]
  469 | #warning "the function pcap_sendqueue_queue() is not available"
      |  ^~~~~~~
stubs.inc:484:2: warning: #warning "the function pcap_sendqueue_transmit() is not available" [-Wcpp]
  484 | #warning "the function pcap_sendqueue_transmit() is not available"
      |  ^~~~~~~
stubs.inc:499:2: warning: #warning "the function pcap_event() is not available" [-Wcpp]
  499 | #warning "the function pcap_event() is not available"
      |  ^~~~~~~
stubs.inc:514:2: warning: #warning "the function pcap_setsampling() is not available" [-Wcpp]
  514 | #warning "the function pcap_setsampling() is not available"
      |  ^~~~~~~
stubs.inc:519:8: error: redefinition of 'struct pcap_samp'
  519 | struct pcap_samp {
      |        ^~~~~~~~~
In file included from /usr/include/pcap.h:43,from Pcap.xs:32:
/usr/include/pcap/pcap.h:1168:8: note: originally defined here
 1168 | struct pcap_samp
      |        ^~~~~~~~~
In file included from Pcap.xs:43:
stubs.inc:524:19: error: conflicting types for 'pcap_setsampling'
  524 | struct pcap_samp *pcap_setsampling(pcap_t *p);
      |                   ^~~~~~~~~~~~~~~~
In file included from /usr/include/pcap.h:43,from Pcap.xs:32:
/usr/include/pcap/pcap.h:1186:28: note: previous declaration of 'pcap_setsampling' was here
 1186 | PCAP_API struct pcap_samp *pcap_setsampling(pcap_t *p);
      |                            ^~~~~~~~~~~~~~~~
In file included from Pcap.xs:43:
stubs.inc:525:19: error: conflicting types for 'pcap_setsampling'
  525 | struct pcap_samp *pcap_setsampling(pcap_t *p) {
      |                   ^~~~~~~~~~~~~~~~
In file included from /usr/include/pcap.h:43,from Pcap.xs:32:
/usr/include/pcap/pcap.h:1186:28: note: previous declaration of 'pcap_setsampling' was here
 1186 | PCAP_API struct pcap_samp *pcap_setsampling(pcap_t *p);
      |                            ^~~~~~~~~~~~~~~~
Pcap.xs: In function 'XS_Net__Pcap_lookupdev':
Pcap.xs:108:4: warning: 'pcap_lookupdev' is deprecated: use 'pcap_findalldevs' and use the first device [-Wdeprecated-declarations]
  108 |    RETVAL = pcap_lookupdev(errbuf);
      |    ^~~~~~
In file included from /usr/include/pcap.h:43,from Pcap.xs:32:
/usr/include/pcap/pcap.h:394:16: note: declared here
  394 | PCAP_API char *pcap_lookupdev(char *)
      |                ^~~~~~~~~~~~~~
Pcap.xs: In function 'XS_Net__Pcap_findalldevs_xs':
Pcap.xs:222:21: warning: 'pcap_lookupdev' is deprecated: use 'pcap_findalldevs' and use the first device [-Wdeprecated-declarations]
  222 |                     char *dev = pcap_lookupdev(errbuf);
      |                     ^~~~
In file included from /usr/include/pcap.h:43,from Pcap.xs:32:
/usr/include/pcap/pcap.h:394:16: note: declared here
  394 | PCAP_API char *pcap_lookupdev(char *)
      |                ^~~~~~~~~~~~~~
Pcap.c: In function 'XS_Net__Pcap_strerror':
Pcap.c:1703:9: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 1703 |  RETVAL = pcap_strerror(error);
      |         ^
Pcap.xs: In function 'XS_Net__Pcap_getevent':
Pcap.xs:1038:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
 1038 |         h = (unsigned int) pcap_getevent(p);
      |             ^
make: *** [Makefile:344: Pcap.o] Error 1
-> FAIL Installing Net::Pcap failed. See /home/nick/.cpanm/work/1612889779.12603/build.log for details. Retry with --force to force install it.

好的,也许常规 cpan 会起作用。

[nick@void ~]$ cpan Net::Pcap
Loading internal logger. Log::Log4perl recommended for better logging
Reading '/home/nick/.cpan/Metadata'
  Database was generated on Tue,09 Feb 2021 14:56:08 GMT
Running install for module 'Net::Pcap'
Checksum for /home/nick/.cpan/sources/authors/id/S/SA/SAPER/Net-Pcap-0.18.tar.gz ok
'YAML' not installed,will not store persistent state
Configuring S/SA/SAPER/Net-Pcap-0.18.tar.gz with Makefile.PL
looking for -lpcap... yes
checking for pcap_lib_version() in -lpcap... yes
detecting available functions... ok
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Net::Pcap
Writing MYMETA.yml and MYMETA.json
  SAPER/Net-Pcap-0.18.tar.gz
  /usr/bin/perl Makefile.PL INSTALLDIRS=site -- OK
Running make for S/SA/SAPER/Net-Pcap-0.18.tar.gz
cp Pcap.pm blib/lib/Net/Pcap.pm
Running Mkbootstrap for Pcap ()
chmod 644 "Pcap.bs"
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Pcap.bs blib/arch/auto/Net/Pcap/Pcap.bs 644
"/usr/bin/perl" "/usr/share/perl5/core_perl/ExtUtils/xsubpp"  -typemap '/usr/share/perl5/core_perl/ExtUtils/typemap' -typemap '/home/nick/.cpan/build/Net-Pcap-0.18-7/typemap'  Pcap.xs > Pcap.xsc
mv Pcap.xsc Pcap.c
cc -c   -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -g -D_FILE_OFFSET_BITS=64 -DLARGE_FILE_SUPPORT64 -Wall -fstack-clash-protection -D_FORTIFY_SOURCE=2 -mtune=generic -O2 -pipe -g -D_FILE_OFFSET_BITS=64 -DLARGE_FILE_SUPPORT64   -DVERSION=\"0.18\" -DXS_VERSION=\"0.18\" -fPIC "-I/usr/lib/perl5/core_perl/CORE"  -DHAVE_BLANK -DHAVE_PCAP_LIB_VERSION -DHAVE_PCAP_BREAKLOOP -DHAVE_PCAP_COMPILE_NOPCAP -DHAVE_PCAP_DATALINK_NAME_TO_VAL -DHAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION -DHAVE_PCAP_DATALINK_VAL_TO_NAME -DHAVE_PCAP_DUMP_FILE -DHAVE_PCAP_DUMP_FLUSH -DHAVE_PCAP_FINDALLDEVS -DHAVE_PCAP_GETNONBLOCK -DHAVE_PCAP_GET_SELECTABLE_FD -DHAVE_PCAP_LIB_VERSION -DHAVE_PCAP_NEXT_EX -DHAVE_PCAP_OFFLINE_FILTER -DHAVE_PCAP_OPEN_DEAD -DHAVE_PCAP_SENDPACKET -DHAVE_PCAP_SETNONBLOCK -DHAVE_PCAP_SET_DATALINK Pcap.c
In file included from Pcap.xs:43:
stubs.inc:187:2: warning: #warning "the function pcap_list_datalinks() is not available" [-Wcpp]
  187 | #warning "the function pcap_list_datalinks() is not available"
      |  ^~~~~~~
stubs.inc:322:2: warning: #warning "the function pcap_createsrcstr() is not available" [-Wcpp]
  322 | #warning "the function pcap_createsrcstr() is not available"
      |  ^~~~~~~
stubs.inc:337:2: warning: #warning "the function pcap_parsesrcstr() is not available" [-Wcpp]
  337 | #warning "the function pcap_parsesrcstr() is not available"
      |  ^~~~~~~
stubs.inc:352:2: warning: #warning "the function pcap_open() is not available" [-Wcpp]
  352 | #warning "the function pcap_open() is not available"
      |  ^~~~~~~
stubs.inc:357:8: error: redefinition of 'struct pcap_rmtauth'
  357 | struct pcap_rmtauth {
      |        ^~~~~~~~~~~~
In file included from /usr/include/pcap.h:43,from Pcap.xs:32:
/usr/include/pcap/pcap.h:394:16: note: declared here
  394 | PCAP_API char *pcap_lookupdev(char *)
      |                ^~~~~~~~~~~~~~
Pcap.c: In function 'XS_Net__Pcap_strerror':
Pcap.c:1703:9: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 1703 |  RETVAL = pcap_strerror(error);
      |         ^
Pcap.xs: In function 'XS_Net__Pcap_getevent':
Pcap.xs:1038:13: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
 1038 |         h = (unsigned int) pcap_getevent(p);
      |             ^
make: *** [Makefile:345: Pcap.o] Error 1
  SAPER/Net-Pcap-0.18.tar.gz
  /usr/bin/make -- NOT OK

没有。

这是我第一次安装 cpan 模块,所以我尝试安装一个随机模块,但效果很好。

[nick@void ~]$ cpanm Regexp::Debugger
--> Working on Regexp::Debugger
Fetching http://www.cpan.org/authors/id/D/DC/DCONWAY/Regexp-Debugger-0.002006.tar.gz ... OK
Configuring Regexp-Debugger-0.002006 ... OK
Building and testing Regexp-Debugger-0.002006 ... OK
Successfully installed Regexp-Debugger-0.002006
1 distribution installed

在这里 libpcap 是一个依赖项是有道理的,但我已经安装了它。

[nick@void ~]$ sudo xbps-install libpcap
Package `libpcap' already installed.

希望得到帮助。

解决方法

问题出在我的 libpcap 版本上。这个包似乎在 libpcap 1.10 和 1.9.1 上被破坏了。安装 libpcap 1.8 后,包构建良好。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-