Perl XS:共享库链接

时间:2016-10-14 11:37:53

标签: perl shared-libraries xs

我是perl的新手,我正在尝试使用XS从我的perl脚本调用特定的C函数。我试图从现在开始从测试脚本调用C函数。我在运行时遇到以下错误“进行测试” -

PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/test.t .. 1/1 
Failed test 'use test;'at t/test.t line 12.Tried to use 'test'. Error:  Can't load '/mnt/workspaces/TOT4/usr.src/netscaler/gslbautosync/test/blib/arch/auto/test/test.so' for module test: /mnt/workspaces/TOT4/usr.src/netscaler/gslbautosync/test/blib/arch/auto/test/test.so: Undefined symbol "pb_register_restartproc" at /usr/local/lib/perl5/5.14.2/mach/DynaLoader.pm line 190.

这是我的Makefile.PL -

    use 5.014002;
    use ExtUtils::MakeMaker;
    WriteMakefile(
    NAME              => 'test',
    VERSION_FROM      => 'lib/test.pm', # finds $VERSION
    PREREQ_PM         => {}, # e.g., Module::Name => 1.1
   ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
    (ABSTRACT_FROM  => 'lib/test.pm', # retrieve abstract from module
     AUTHOR         => 'Charlie & <root@isc.freebsd.org>') : ()),
  LIBS              => ['-L../../libnsapps/.obj/$(MACHINE_ARCH) -L../../libpb/.obj/$(MACHINE_ARCH) '],
   DEFINE            => '-g -DDEBUG -DDEBUG2 -Wall -Dunix -fPIC -DLINUX ',
   INC               => '-I../../../..', # e.g., '-I. -I/usr/include/other'
      # Un-comment this if you add C files to link with later:
  # OBJECT            => '$(O_FILES)', # link all the C files too

);
这是我的test.xs -

#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
MODULE = test           PACKAGE = test
int
pb_register_restartproc(action)
              char *action
      CODE:
              extern int pb_register_restartproc(char *action);
              RETVAL = pb_register_restartproc(action);
      OUTPUT:
              RETVAL

0 个答案:

没有答案