0

我正在寻找有关如何使用 perl 运行 SIGAR API 的任何信息或说明。我查看了放置 Makefile.PL 并创建了 makefile 的绑定目录,然后运行了 make 命令,一切正常,但我无法运行任何示例。我还粘贴了运行“exmaples”目录中列出的示例程序时出现的错误。如果我遗漏任何东西,请告诉我。

[oracle@mercury perl]$ perl Makefile.PL
Sigar_generated.xs needs update
generating Sigar_generated.xs
Warning: -L../../sigar-bin/lib changed to -L/u01/test/hyperic-sigar-1.6.4/bindings/perl/../../sigar-bin/lib
Writing Makefile for Sigar
[oracle@mercury perl]$ make
cp Sigar.pm blib/lib/Sigar.pm
/usr/bin/perl /usr/lib/perl5/5.8.8/ExtUtils/xsubpp  -typemap /usr/lib/perl5/5.8.8/ExtUtils/typemap -typemap typemap  Sigar.xs                                                                        > Sigar.xsc && mv Sigar.xsc Sigar.c
gcc -c  -I../../sigar-bin/include -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/l                                                                       ocal/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexcep                                                                       tions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic   -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" -fPIC "-I/usr                                                                       /lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE"  -Wall -Werror Sigar.c
Running Mkbootstrap for Sigar ()
chmod 644 Sigar.bs
rm -f blib/arch/auto/Sigar/Sigar.so
gcc  -shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=g                                                                       eneric Sigar.o  -o blib/arch/auto/Sigar/Sigar.so        \
           -L/u01/test/hyperic-sigar-1.6.4/bindings/perl/../../sigar-bin/lib -lsigar-amd64-linux        \

chmod 755 blib/arch/auto/Sigar/Sigar.so
cp Sigar.bs blib/arch/auto/Sigar/Sigar.bs
chmod 644 blib/arch/auto/Sigar/Sigar.bs
[oracle@mercury perl]$ cd examples
[oracle@mercury examples]$ ls
cpu_info.pl  df.pl  free.pl  ifconfig.pl






[oracle@mercury examples]$ perl free.pl
Can't locate Sigar.pm in @INC (@INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib64/perl5/site                                                                       _perl/5.8.7/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.6/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.                                                                       8.5/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /us                                                                       r/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib64/p                                                                       erl5/vendor_perl/5.8.7/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.6/x86_64-linux-thread-multi /usr/lib64/perl5                                                                       /vendor_perl/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/                                                                       vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi                                                                        /usr/lib/perl5/5.8.8 .) at free.pl line 19.
BEGIN failed--compilation aborted at free.pl line 19.

Ran Make install 和 make test

[root@mercury perl]# make install
Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/Sigar/Sigar.so
Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/Sigar/Sigar.bs
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/Sigar.pm
Writing /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/Sigar/.packlist
Appending installation info to /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod
[root@mercury perl]# make test
No tests defined for Sigar extension.
[root@mercury perl]# cd examples
[root@mercury examples]# ls
cpu_info.pl  df.pl  free.pl  ifconfig.pl

[root@mercury examples]# perl ifconfig.pl
Can't load '/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/Sigar/Sigar.so' for module Sigar: libsigar-amd64-linux.so: cannot open shared object file: No such file or directory at /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/XSLoader.pm line 70.
 at /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/Sigar.pm line 36
Compilation failed in require at ifconfig.pl line 19.
BEGIN failed--compilation aborted at ifconfig.pl line 19.
4

2 回答 2

1

尝试将libsigar-amd64-linux.so库放到 Linux 库加载器已知的位置,并明确告诉 ExtUtils::MakeMaker 路径:

…/sigar/bindings/perl$ perl Makefile.PL LIBS=-L/usr/lib64 INC=-I../../include
于 2012-08-16T17:33:00.707 回答
0

我已将以下内容包含在库路径中,这有帮助。

导出 LD_LIBRARY_PATH=/u01/test/hyperic-sigar-1.6.4/bindings/perl/../../sigar-bin/lib:/usr/lib64

[root@mercury examples]# perl df.pl
Filesystem      Size    Used    Avail   Use%    Mounted on      Type
/dev/mapper/VolGroup00-LogVol00 194G    4.4G    179G    3%      /       ext3/local
proc      0       0       0     -       /proc   proc/none
sysfs     0       0       0     -       /sys    sysfs/none
devpts    0       0       0     -       /dev/pts        devpts/none
/dev/mapper/VolGroup00-LogVol02 695G    4.2G    655G    1%      /u01    ext3/local
/dev/sda1       190M     13M    167M    8%      /boot   ext3/local
tmpfs   5.7G      0     5.7G    -       /dev/shm        tmpfs/none
none      0       0       0     -       /proc/sys/fs/binfmt_misc        binfmt_misc/none
sunrpc    0       0       0     -       /var/lib/nfs/rpc_pipefs rpc_pipefs/none
none    5.7G    104K    5.7G    -       /var/lib/xenstored      tmpfs/none
于 2012-08-16T17:58:00.320 回答