net-snmp在执行configure命令时找不到perl的api函数

linuxstudy 发布于 2015/01/30 09:35
阅读 2K+
收藏 0

@Yisen 你好,想跟你请教个问题:

@北极的雪 你好,想跟你请教个问题:

执行./configure后会有如下错误:好像是找不到perl的api函数。但是我把perl的源码下载后也重新编译了。perl -v 的信息也有。你帮我看下是什么回事?

checking for eval_pv... no
checking for perl_eval_pv... no
checking for Perl_eval_pv... no
configure: error: Could not find the eval_pv, perl_eval_pv or Perl_eval_pv functions needed for embedded Perl support. Either set the environment variable PERLPROG to a different perl binary or use --disable-embedded-perl to turn off embedded Perl functionality altogether.
[root@0 net-snmp-5.7.3]# cd perl

[root@0 perl]# perl -v

This is perl 5, version 16, subversion 3 (v5.16.3) built for i686-linux

Copyright 1987-2012, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

 

以下是问题补充:

@linuxstudy:1 执行mib2c命令时,在文件是不agent_module_inits.h是应该自动生成如下内容? if (should_init("ifNumber")) init_ifNumber(); agent_module_inits.h文件的目前内容如下 : /* This file is automatically generated by configure. Do not modify by hand. */ if (should_init("usmConf")) init_usmConf(); if (should_init("iquery")) init_iquery(); if (should_init("vacm_conf")) init_vacm_conf(); 2 在文件中default_modules.h添加内容如下: (2015/01/30 16:29)
@linuxstudy:config_require(mibII/ifNumber) config_add_mib(RFC1213-MIB) (2015/01/30 16:30)
加载中
0
huangyanxiong
huangyanxiong

--disable-embedded-perl   如果不需要Perl的支持可以加上

set the environment variable PERLPROG to a different perl binary  设置这个PERLPROG  环境变量到一个Perl 二进制目录  paht/perl/bin

设置一个环境变量 export HELLO="Hello!"


0
linuxstudy
linuxstudy

引用来自“huangyanxiong”的评论

--disable-embedded-perl   如果不需要Perl的支持可以加上

set the environment variable PERLPROG to a different perl binary  设置这个PERLPROG  环境变量到一个Perl 二进制目录  paht/perl/bin

设置一个环境变量 export HELLO="Hello!"


如果不编译perl模块的话,现在的错误是这样的:

 -lrt -lcrypto -L/usr/local/lib -L/usr/local/lib/perl5/5.16.3/i686-linux/CORE -lperl -lnsl -ldl -lcrypt -lutil -lc -lm  --sysroot=/media/disk2/loongson/sysroot -fstack-protector -Wl,-E -Wl,-rpath -Wl,/usr/local/lib/perl5/5.16.3/i686-linux/CORE -fstack-protector   -Wl,-soname -Wl,libnetsnmpagent.so.30 -o .libs/libnetsnmpagent.so.30.0.2
/opt/gcc-4.4-ls232/lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: skipping incompatible /usr/local/lib/perl5/5.16.3/i686-linux/CORE/libperl.so when searching for -lperl
/opt/gcc-4.4-ls232/lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: cannot find -lperl
collect2: ld returned 1 exit status
make: *** [libnetsnmpagent.la] 错误 1
make: Leaving directory `/media/disk2/loongson/netsnmp/net-snmpsrc/net-snmp-5.7.2.1/agent'

 

linuxstudy
linuxstudy
但其实libperl.so这个库是存在的。不知道什么原因。
0
huangyanxiong
huangyanxiong

引用来自“huangyanxiong”的评论

--disable-embedded-perl   如果不需要Perl的支持可以加上

set the environment variable PERLPROG to a different perl binary  设置这个PERLPROG  环境变量到一个Perl 二进制目录  paht/perl/bin

设置一个环境变量 export HELLO="Hello!"


引用来自“linuxstudy”的评论

如果不编译perl模块的话,现在的错误是这样的:

 -lrt -lcrypto -L/usr/local/lib -L/usr/local/lib/perl5/5.16.3/i686-linux/CORE -lperl -lnsl -ldl -lcrypt -lutil -lc -lm  --sysroot=/media/disk2/loongson/sysroot -fstack-protector -Wl,-E -Wl,-rpath -Wl,/usr/local/lib/perl5/5.16.3/i686-linux/CORE -fstack-protector   -Wl,-soname -Wl,libnetsnmpagent.so.30 -o .libs/libnetsnmpagent.so.30.0.2
/opt/gcc-4.4-ls232/lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: skipping incompatible /usr/local/lib/perl5/5.16.3/i686-linux/CORE/libperl.so when searching for -lperl
/opt/gcc-4.4-ls232/lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: cannot find -lperl
collect2: ld returned 1 exit status
make: *** [libnetsnmpagent.la] 错误 1
make: Leaving directory `/media/disk2/loongson/netsnmp/net-snmpsrc/net-snmp-5.7.2.1/agent'

 

设置那个环境变量试试
huangyanxiong
huangyanxiong
回复 @linuxstudy : 先试试
linuxstudy
linuxstudy
export PERLPROG=/usr/bin/perl 执行了上述命令,还是不能找到api函数。上面的那个命令对吗?
0
linuxstudy
linuxstudy

引用来自“huangyanxiong”的评论

--disable-embedded-perl   如果不需要Perl的支持可以加上

set the environment variable PERLPROG to a different perl binary  设置这个PERLPROG  环境变量到一个Perl 二进制目录  paht/perl/bin

设置一个环境变量 export HELLO="Hello!"


引用来自“linuxstudy”的评论

如果不编译perl模块的话,现在的错误是这样的:

 -lrt -lcrypto -L/usr/local/lib -L/usr/local/lib/perl5/5.16.3/i686-linux/CORE -lperl -lnsl -ldl -lcrypt -lutil -lc -lm  --sysroot=/media/disk2/loongson/sysroot -fstack-protector -Wl,-E -Wl,-rpath -Wl,/usr/local/lib/perl5/5.16.3/i686-linux/CORE -fstack-protector   -Wl,-soname -Wl,libnetsnmpagent.so.30 -o .libs/libnetsnmpagent.so.30.0.2
/opt/gcc-4.4-ls232/lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: skipping incompatible /usr/local/lib/perl5/5.16.3/i686-linux/CORE/libperl.so when searching for -lperl
/opt/gcc-4.4-ls232/lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: cannot find -lperl
collect2: ld returned 1 exit status
make: *** [libnetsnmpagent.la] 错误 1
make: Leaving directory `/media/disk2/loongson/netsnmp/net-snmpsrc/net-snmp-5.7.2.1/agent'

 

引用来自“huangyanxiong”的评论

设置那个环境变量试试

/media/disk2/loongson/netsnmp/net-snmpsrc/net-snmp-5.7.2.1

在该目录下执行configure配置的命令:

 CC="mipsel-linux-gcc --sysroot=/media/disk2/loongson/sysroot" ./configure --host=mipsel-linux --build=i686-pc-linux-gnu --target=mipsel-linux --with-endianness=little --enable-shared=yes --enable-mini-agent --disable-manuals --disable-scripts  --with-cflags=-g --without-perl-module --disable embeddedperl  --disable-perl-cc-checks

加入了红色的配置选项,可以configure成功,接下来执行make&make install命令都可以成功。但是在net-snmp安装目录/usr/local/share/snmp/mibs执行mib2c命令时,会提示下面错误:

 

[root@0 local]# cd share/snmp/mibs/
[root@0 mibs]# mib2c

ERROR: You don't have the SNMP perl module installed.  Please obtain
this by getting the latest source release of the net-snmp toolkit from
http://www.net-snmp.org/download/ .  Once you download the source and
unpack it, the perl module is contained in the perl/SNMP directory.
See the README file there for instructions.

[root@0 mibs]# perl -v

This is perl 5, version 16, subversion 3 (v5.16.3) built for i686-linux

Copyright 1987-2012, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

 

 

0
leo108
leo108

yum install -y perl-devel

在centos/redhat/fedora上编译东西遇到类似这种找不到库的错时,就试试yum install 库名-devel

0
linuxstudy
linuxstudy

引用来自“leo108”的评论

yum install -y perl-devel

在centos/redhat/fedora上编译东西遇到类似这种找不到库的错时,就试试yum install 库名-devel

其实已经安装了perl。不知道为什么执行mib2c时还是会显示没有安装。

[root@0 net-snmp-5.7.2.1]# perl -v

This is perl 5, version 16, subversion 3 (v5.16.3) built for i686-linux

Copyright 1987-2012, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

[root@0 net-snmp-5.7.2.1]# yum install -y perl-devel
已加载插件:presto, refresh-packagekit
http://linuxdownload.adobe.com/linux/i386/repodata/repomd.xml: [Errno 14] PYCURL ERROR 6 - ""
尝试其他镜像。
设置安装进程
包 4:perl-devel-5.10.1-123.fc13.i686 已安装并且是最新版本
无须任何处理

0
huangyanxiong
huangyanxiong

引用来自“huangyanxiong”的评论

--disable-embedded-perl   如果不需要Perl的支持可以加上

set the environment variable PERLPROG to a different perl binary  设置这个PERLPROG  环境变量到一个Perl 二进制目录  paht/perl/bin

设置一个环境变量 export HELLO="Hello!"


引用来自“linuxstudy”的评论

如果不编译perl模块的话,现在的错误是这样的:

 -lrt -lcrypto -L/usr/local/lib -L/usr/local/lib/perl5/5.16.3/i686-linux/CORE -lperl -lnsl -ldl -lcrypt -lutil -lc -lm  --sysroot=/media/disk2/loongson/sysroot -fstack-protector -Wl,-E -Wl,-rpath -Wl,/usr/local/lib/perl5/5.16.3/i686-linux/CORE -fstack-protector   -Wl,-soname -Wl,libnetsnmpagent.so.30 -o .libs/libnetsnmpagent.so.30.0.2
/opt/gcc-4.4-ls232/lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: skipping incompatible /usr/local/lib/perl5/5.16.3/i686-linux/CORE/libperl.so when searching for -lperl
/opt/gcc-4.4-ls232/lib/gcc/mipsel-linux/4.4.0/../../../../mipsel-linux/bin/ld: cannot find -lperl
collect2: ld returned 1 exit status
make: *** [libnetsnmpagent.la] 错误 1
make: Leaving directory `/media/disk2/loongson/netsnmp/net-snmpsrc/net-snmp-5.7.2.1/agent'

 

引用来自“huangyanxiong”的评论

设置那个环境变量试试

引用来自“linuxstudy”的评论

/media/disk2/loongson/netsnmp/net-snmpsrc/net-snmp-5.7.2.1

在该目录下执行configure配置的命令:

 CC="mipsel-linux-gcc --sysroot=/media/disk2/loongson/sysroot" ./configure --host=mipsel-linux --build=i686-pc-linux-gnu --target=mipsel-linux --with-endianness=little --enable-shared=yes --enable-mini-agent --disable-manuals --disable-scripts  --with-cflags=-g --without-perl-module --disable embeddedperl  --disable-perl-cc-checks

加入了红色的配置选项,可以configure成功,接下来执行make&make install命令都可以成功。但是在net-snmp安装目录/usr/local/share/snmp/mibs执行mib2c命令时,会提示下面错误:

 

[root@0 local]# cd share/snmp/mibs/
[root@0 mibs]# mib2c

ERROR: You don't have the SNMP perl module installed.  Please obtain
this by getting the latest source release of the net-snmp toolkit from
http://www.net-snmp.org/download/ .  Once you download the source and
unpack it, the perl module is contained in the perl/SNMP directory.
See the README file there for instructions.

[root@0 mibs]# perl -v

This is perl 5, version 16, subversion 3 (v5.16.3) built for i686-linux

Copyright 1987-2012, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

 

 

安装前看一下readme自述文件,一般都会写上安装方法的,你贴出来
linuxstudy
linuxstudy
http://www.net-snmp.org/download.html 安装的net-snmp源码包是在这个官网下载的。下载后里面有readme和FAQ,其实我都看了,但没看出来解决问题的办法。你抽时间帮我下载看看啊。谢谢
0
linuxstudy
linuxstudy

net-snmp-5.7.3版本的README内容:

This directory holds the implementation of individual MIB groups.
Currently, this contains the eight MIB-2 groups, plus a basic template
for new MIB groups (examples/example.c and examples/example.h)

Additionally, you may wish to check out the 'mib2c' perl script in the
SRCDIR/local directory that can convert a written mib into C template
files for use with this package as mib modules.

Each group consists of two files:

  examples/example.h: interface information

 - declaration of the initialisation function 'init_example'
  (optional)
 - declaration of the function(s) for retrieving variable
  information 'var_example'
 - declaration of the function(s) for setting variable
  information (if appropriate)

 - declaration of the function(s) for parsing the snmpd.conf file
  (optional)
        - a call to config_parse_dot_conf() to explain to the .conf
  parser which tokens we want to parse.
  (optional)

 - definitions of the MIB group 'magic numbers'
  declarations of the 'public' functions

 - a list of the variables in the group, including
  type information, mapping between magic numbers
  and OID sub-identifiers within the group,
  accessibility information, and the relevant
  function for retrieving this variable's value.
                They *must* be listed in the mib-descending order.
 - a call to 'config_load_mib', identifying the location of
  this MIB group within the general MIB structure.
 - a call to 'config_require' to identify any other files
  that are required by the implementation of this group.
  (optional)

    (these last three are only visible within the 'glue' file 'snmp_vars.c'
 (if at all), but are declared here for ease of maintainance)

 

  examples/example.c: implementation code
  (can be non-existant if only the .h file is needed)

 - a list of kernel information needed to report
  on this group
 - an initialisation function (optional)
        - a routine to parse an snmpd.conf line.
        - a routine to free resources from above and return to
                default settings.
 - 'header' function(s) to map the OID requested
  to the next appropriate OID
  (and similar system-independent setup)
 - function(s) (possibly system-specific) to
  determine and return the value of the
  variable requested.
 - (optionally) functions used to set values
 - other functions used internally


To implement a new MIB group, copy the two files 'example.c'
and 'example.h' to appropriate new files ({MODULENAME}.c and {MODULENAME}.h),
and edit them as follows:

 example.h:
  globally change "example" to the new module name
      and update the initial comment.
  replace the EXAMPLE* defines with the list of
      variables within this new group
  fill in the 'MODULENAME_variables' structure with these
      new variables, updating the type, accessibility
      and sub-identifier information as appropriate.
  replace 'variableN' with the maximum size of the
      returned OID (omitting the group prefix).
      For non-table values, this will probably be one
      greater than the length of the sub-identifier.
                update or remove the 'config_parse_dot_conf' call if
                    you need to handle lines in the snmpd.conf files.
  update the 'config_load_mib' call with the appropriate
      location within the global MIB structure, and
      its length (note that 'MIB' has length 6)
  provide a suitable 'config_require' call if this
      code uses routines from any other files within
      the 'mibgroup' directory (such as 'util_funcs.c')

 

 example.c:
  globally change "example" to the new module name
      and update the initial comment.
  replace the 'MODULENAME_nl' name list with any necessary
      kernel variables, and update the associated #define's
  replace the name length definition within the 'header'
      function with the length of the requesting OID
      (i.e. the sum of the lengths given in the subtree
       definition, and the variable structure above).
  replace the basic 'switch' structure within the
      'var_MODULENAME' function with the necessary code
      to calculate the required information.
  (plus any other internal functions as needed).

  It will then be necessary to (re-)run the configure script with the
option
 --with-mib-modules="MODULENAME"

(where MODULENAME matches the name of the .c/.h file pair exactly).
Note that if anything in the config_* macros changes, or the init function
is added or removed, then the configure script will need to be re-run.

 

返回顶部
顶部