问题
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