CPAN installing Net::Pcap and Packet module failed due to lpcap

浪子不回头ぞ 提交于 2019-11-28 13:13:32

问题


Recently, I tried to install perl module Net::Packet and Net::Pcap through cpan but it complained that it cannot find pcap library. So I was searching if cpan would accept external lib/include directory when installing module, but no luck til now.

looking for -lpcap... no
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
You appear to lack the pcap(3) library. 

If it is installed in a non-standard locatio n, please try setting the LIBS 
and INC values on the command line.

Or get the sources and install the pcap library from http://www.tcpdump.org/

If you install the pcap library using a system package, make sure to also 
install the corresponding -devel package, which contains the C headers needed 
to compile this module. 
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

my pcap library is located at /opt/local/lib and header at /opt/local/include/pcap. Anyone know how to solve this issue? Thanks


回答1:


The README file for Net::Pcap shows how to tell Makefile.PL where to find the pcap library:

perl Makefile.PL INC=-I/opt/local/include/pcap LIBS='-L/opt/local/lib -lpcap'

(I've inserted your paths into the example.)

However, getting the cpan shell to pass those arguments to Makefile.PL is rather more complicated. You'd have to use the Distroprefs system and create a YAML file to supply the arguments. If you're not already familiar with Distroprefs, it'll probably be easier to just install Net::Pcap by hand.




回答2:


This fixed my issue:

yum -y install perl-Net-Pcap libpcap-devel



回答3:


On Ubuntu, just install libnet-pcap-perl.



来源:https://stackoverflow.com/questions/7489966/cpan-installing-netpcap-and-packet-module-failed-due-to-lpcap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!