【问题标题】:How could I clear a perl script error in implementing the net-snmp agent?如何在实现 net-snmp 代理时清除 perl 脚本错误?
【发布时间】:2022-07-19 03:54:50
【问题描述】:

我现在通过引用这个站点在 Ubuntu 16.04 上实现 net-snmp 代理 (https://kadionik.vvv.enseirb-matmeca.fr/embedded/snmp/english/net-snmp_english.html)

但我停在了“4.2 NET-SNMP 代理扩展”

当我执行‘perl Makefile.PL’时,显示如下错误信息。(perl version : 5.22.1)

无法在 @INC 中找到 MakefileSubs.pm(您可能需要安装 MakefileSubs 模块)(@INC 包含:/etc/perl /usr/local/lib/arm-linux-gnueabihf/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/arm-linux-gnueabihf/perl5/5.22 /usr/share/perl5 /usr/lib/arm-linux-gnueabihf/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/arm-linux-gnueabihf/perl-base .) 在 Makefile.PL 第 7 行。开始 failed--编译在 Makefile.PL 第 7 行中止。

以下是 Perl 脚本。

use strict;
use warnings;
use ExtUtils::MakeMaker;
require 5;
use Config;
use Cwd 'abs_path';
use MakefileSubs;

my $lib_version;

WriteMakefile(DefaultStoreInitMakeParams());

sub DefaultStoreInitMakeParams {
    my $opts;
    my %Params = (
      'NAME'        => 'NetSNMP::default_store',
      'VERSION_FROM'    => 'default_store.pm', # finds $VERSION
      'XSPROTOARG'          => '-prototypes',
      );

AddCommonParams(\%Params);
              
my ($snmp_lib, $snmp_llib, $sep);

$opts = NetSNMPGetOpts();

if ($Config{'osname'} eq 'MSWin32' && !defined($ENV{'OSTYPE'})) {
  $sep = '\\';
  my $snmp_lib_file = 'netsnmp.lib';
  my $snmp_link_lib = 'netsnmp';
  my $lib_dir;

  if (lc($opts->{'debug'}) eq "true") {
    $lib_dir = 'lib\\debug';
  }
  else {
    $lib_dir = 'lib\\release';
  }
  
  if (lc($opts->{'insource'}) eq "true") {
$Params{'LIBS'} = "-L" . $MakefileSubs::basedir . "\\win32\\$lib_dir\\ -l$snmp_link_lib";
  }
  else {
my @LibDirs = split($Config{path_sep}, $ENV{LIB});
    my $LibDir;
if ($opts->{'prefix'}) {
  push (@LibDirs,"$ENV{'NET-SNMP-PATH'}${sep}lib");
}
my $noLibDir = 1;
while ($noLibDir) {
  $LibDir = find_files(["$snmp_lib_file"],\@LibDirs);
  if ($LibDir ne '') {
    $noLibDir = 0;
        # Put quotes around LibDir to allow spaces in paths
        $LibDir = '"' . $LibDir . '"';
  }
  else
  {
    @LibDirs = ();
    $LibDirs[0] = prompt("The Net-SNMP library ($snmp_lib_file) could not be found.\nPlease enter the directory where it is located:");
    $LibDirs[0] =~ s/\\$//;
  }
}
$Params{LIBS} = "-L$LibDir -l$snmp_link_lib";
  }
}
else {
$Params{'LIBS'}    = `$opts->{'nsconfig'} --libs` or
    die "net-snmp-config failed\n";
chomp($Params{'LIBS'});
    $lib_version = `$opts->{'nsconfig'} --version` or
    die "net-snmp-config failed\n";
if (lc($opts->{'insource'}) eq "true") {
    $Params{'LIBS'} =
            "-L" . abs_path("../../snmplib/.libs") .
            " -L" . abs_path("../../snmplib") .
            " " . $Params{'LIBS'};
}
}

return(%Params);
}

我查看了许多解决此问题的建议,并安装了一些软件包,“libsnmp-perl”、“libnet-snmp-perl”。

但我还没有解决这个问题。

【问题讨论】:

    标签: perl net-snmp


    【解决方案1】:

    net-snmp 发行版(不是 Perl 模块)有一个名为 perl/ 的目录和一个 Makefile.PL。我假设你在这个目录中。在 perl/ 下,有一个名为 MakefileSubs.pm 的文件。要让 Perl 程序加载它,它需要知道在当前目录中查找 MakefileSubs.pm。当您查看错误消息时,您会看到 perl 搜索的目录列表;那里好像没有.

    顺便说一句,当前的工作目录.removed from the default module search path in Perl v5.26,但您使用的是早期版本,看起来有人决定为默认搜索路径设置一组不同的目录。

    一种方法是使用-I 开关指定附加目录,并将. 用于当前目录:

    perl -I. Makefile.PL
    

    您还可以将此目录添加到 PERL5LIB 环境变量中,以便会话中的任何内容也将搜索该目录:

    % export PERL5LIB = .:$PERL5LIB
    

    How do I add a directory to my include path (@INC) at runtime?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-29
      • 2019-07-18
      • 1970-01-01
      相关资源
      最近更新 更多