2012-04-13 93 views
10

我試圖編譯XS到perl的[ED(池上):這是說他的使用:: MakeMaker的的make perl創建具有靜態鏈接在C供應商庫perl]但是當我這樣做時,新版本的perl不支持動態加載模塊。任何時候,我嘗試運行具有類似use Socket(或任何其他模塊)Perl代碼,我得到:擴展Perl是打破動態加載

Can't load module Socket, dynamic loading not available in this perl. 

是否有一個編譯器/連接器開關我設置不正確的東西?所有這些都是在1998年和2004年在另一個盒子上(PA-RISC上的hpux舊版)編譯​​的,但是我們正在轉向一個新盒子(hpux11 itanium),並且我正在碰壁。

這裏是我的Makefile.PL:

use ExtUtils::MakeMaker; 
# See lib/ExtUtils/MakeMaker.pm for details of how to influence 
# the contents of the Makefile that is written. 
WriteMakefile(
    'NAME'  => 'Udtutil', 
    'VERSION_FROM' => 'Udtutil.pm', # finds $VERSION 
    'LIBS'  => '-L/usr/ud/PFUSION/Udtutil -L/usr/ud/lib -lapidummy ' . 
        '-lshare -ludsql -ludmach -lbasic ' . 
        '-lperf -lret1 -lides -lpipe -lfunc -lndx -lrep -lshm ' . 
        '-lmglm -lulc -lglm -ltpmem2 -lcmn ' . 
        '-llicn -ludus -lunix -lbci -lunirpc -lxmldl -leda ' . 
        '-lsslU2097e -lcryptoU2097e ' . 
        '-lodbc -lstd_v2 -lstream -lCsup -lpthread -lm -lcl ' . 
        '-ldld ' . 
        '-lnfaclnt -lodsdummy -lcl ' . 
        '-lCsup -lcl -lelf -lm -lcurses -lsec -lpam ', 
    'INC'  => '-I/usr/ud/include',  # e.g., '-I/usr/include/other' 
    'OPTIMIZE' => '-O -Ae +DD64 -q -z +u4 -w ', 
    'LINKTYPE' => 'dynamic', 
    'OBJECT' => '$(BASEEXT)$(OBJ_EXT) funchead.o interfunc.o callcf.o efs_init.o', 
); 

這是我的.xs文件,Udtutil.xs

#ifdef __cplusplus 
extern "C" { 
#endif 
#include "EXTERN.h" 
#include "perl.h" 
#include "XSUB.h" 
#include "/usr/ud/include/share.h" 
#include "/opt/iibase/PFUSION/Udtutil/udtutil.h" 
#ifdef __cplusplus 
} 
#endif 

extern int U_IGNSIGSET; 

extern int Iflags[2]; 

#if OS_NT 

#define U_backsig(ignsigcnt) { if (((U_IGNSIGSET=(ignsigcnt)) == 0) && (Iflags[0] || Iflags[1])) U_sig_resend(); if (!U_IGNSIGSET && pU_sigflags && U_sigflags) NT_sig_kill(); } 

#else 

#define U_backsig(ignsigcnt) { if (((U_IGNSIGSET=(ignsigcnt)) == 0) && (Iflags[0] || Iflags[1])) U_sig_resend(); } 

#endif 

MODULE = Udtutil    PACKAGE = Udtutil 

int startudt(value1,value2) 
    int value1 
    int value2 

    CODE: 
    int jmpret, sat; 

    U_SET_JMP(jmpret,sat); 
    if (jmpret) { 
      /* proceed with initialization */ 
      udtcallbasic_init(value1,value2); 
      RETVAL = 1; 
    } else { 
      /* shutdown unibasic and return unsuccessful value */ 
      udtcallbasic_done(1); 
      RETVAL = 0; 
    } 

    OUTPUT: 
    RETVAL 

void stopudt(status) 
    int status 

    CODE: 
    udtcallbasic_done(status); 

void calludt(progname, argcount, ...) 
    char * progname 
    int argcount 

    PPCODE: 
    char * returnval; 
    int paramspassed = 0; 
    int status = 0; 
    char ** arglist = NULL; 
    int i; 

    if (argcount + 2 == items) { 
      /* build the C array from the Perl array */ 
      paramspassed = 1; 
      arglist = (char **)malloc(argcount); 
      for (i = 0; i < argcount; i++) { 
        arglist[i] = (char *)malloc(sv_len(ST(i+2))+1); 
        strcpy(arglist[i], SvPV(ST(i+2),PL_na)); 
      } 

      /* make the call into the database */ 
      status = U_callbas(&returnval, progname, argcount, arglist); 

      for (i = 0; i < argcount; i++) { 
        free(arglist[i]); 
      } 
      free(arglist); 

      /* EXTEND(sp, 2); */ 
      XPUSHs(sv_2mortal(newSViv(paramspassed))); 
      XPUSHs(sv_2mortal(newSViv(status))); 

      if (status == 0) { 
        /* EXTEND(sp, 1); */ 
        XPUSHs(sv_2mortal(newSVpv(returnval, 0))); 
        free(returnval); 
      } 
    } else { 
      /* EXTEND(sp, 1); */ 
      XPUSHs(sv_2mortal(newSViv(paramspassed))); 
    } 

當我運行perl Makefile.PL,一切看起來不錯:

> perl Makefile.PL 
Checking if your kit is complete... 
Looks good 
Writing Makefile for Udtutil 
Writing MYMETA.yml 

當我運行makemake perl時,一切都很順利,它創建了一個ne w本地Perl二進制文件。

然而,當我執行./perl mytest.pl,如果mytest.pl * 使用 * S的任何模塊,我得到:

Can't load module Socket, dynamic loading not available in this perl. 

我如何能編譯這個新的Perl,仍然保持動態加載的工作有什麼建議?


附加信息:

這裏是從舊箱配置數據(即作品的一個):

> perl -V:usedl 
usedl='define'; 

> perl -V 
Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration: Platform: 
    osname=hpux, osvers=10, archname=PA-RISC2.0 
    uname='hp-ux autocrft b.10.20 u 9000893 341130351 unlimited-user license ' 
    hint=recommended, useposix=true, d_sigaction=define 
    bincompat3=y useperlio=undef d_sfio=undef Compiler: 
    cc='cc', optimize='-O', gccversion= 
    cppflags='-D_HPUX_SOURCE -Aa' 
    ccflags ='-D_HPUX_SOURCE -Aa' 
    stdchar='unsigned char', d_stdstdio=define, usevfork=false 
    voidflags=15, castflags=0, d_casti32=define, d_castneg=define 
    intsize=4, alignbytes=8, usemymalloc=y, prototype=define Linker and Libraries: 
    ld='ld', ldflags ='-L/usr/local/lib -L/usr/ud/lib' 
    libpth=/usr/local/lib /usr/lib/pa1.1 /usr/ud/lib /lib /usr/lib /usr/ccs/lib 
    libs=-lnet -lnsl_s -lndbm -ldld -lm -lc -lndir -lcrypt 
    libc=/lib/libc.sl, so=sl 
    useshrplib=false, libperl=libperl.a 
    Dynamic Linking: 
    dlsrc=dl_hpux.xs, dlext=sl, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-B,deferred ' 
    cccdlflags='+z', lddlflags='-b -L/usr/local/lib -L/usr/ud/lib' 


Characteristics of this binary (from libperl): Built under hpux 
Compiled at May 7 1998 13:59:51 @INC: 
    /opt/perl5/lib/PA-RISC2.0/5.00404 
    /opt/perl5/lib 
    /opt/perl5/lib/site_perl/PA-RISC2.0 
    /opt/perl5/lib/site_perl 
    . 

...這裏是新箱配置數據(不工作的那個):

> ./perl -V:usedl 
usedl='define'; 

> ./perl -V 
Summary of my perl5 (revision 5 version 14 subversion 2) configuration: 
     Platform: 
    osname=hpux, osvers=11.31, archname=IA64.ARCHREV_0-LP64 
    uname='hp-ux autocrft b.11.31 u ia64 1650208369 unlimited-user license ' 
    config_args='' 
    hint=previous, useposix=true, d_sigaction=define 
    useithreads=undef, usemultiplicity=undef 
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef 
    use64bitint=define, use64bitall=define, uselongdouble=undef 
    usemymalloc=n, bincompat5005=undef Compiler: 
    cc='cc', ccflags ='+DD64 -Ae -D_HPUX_SOURCE -Wl,+vnocompatwarnings -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', 
    optimize='+O2 +Onolimit', 
    cppflags='-Aa -D__STDC_EXT__ -D_HPUX_SOURCE +DD64 -Ae -D_HPUX_SOURCE -Wl,+vnocompatwarnings -I/usr/local/include +DD64 -Ae -D_HPUX_SOURCE -Wl,+vnocompatwarn ings -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64' 
    ccversion='B3910B', gccversion='', gccosandvers='' 
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=87654321 
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 
    alignbytes=8, prototype=define Linker and Libraries: 
    ld='/usr/bin/ld', ldflags =' -L/usr/lib/hpux64' 
    libpth=/usr/lib/hpux64 
    libs=-L/usr/lib/hpux64 -lnsl -lnm -ldl -ldld -lm -lsec -lc 
    perllibs=-lnsl -lnm -ldl -ldld -lm -lsec -lc 
    libc=/usr/lib/hpux64/libc.so, so=so, useshrplib=false, libperl=libperl.a 
    gnulibc_version='' 
    Dynamic Linking: 
    dlsrc=dl_hpux.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-B,deferred ' 
    cccdlflags='+DD64', lddlflags='-b +vnocompatwarnings' 


Characteristics of this binary (from libperl): 
Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP 
         PERL_PRESERVE_IVUV USE_64_BIT_ALL USE_64_BIT_INT 
         USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF Built under hpux 
Compiled at Apr 13 2012 09:27:33 
    @INC: 
    /opt/iibase/perl/lib/site_perl/5.14.2/IA64.ARCHREV_0-LP64 
    /opt/iibase/perl/lib/site_perl/5.14.2 
    /opt/iibase/perl/lib/5.14.2/IA64.ARCHREV_0-LP64 
    /opt/iibase/perl/lib/5.14.2 
    . 
+0

看看'perl -V'的輸出;它顯示了它是如何編譯的。顯然,它是在沒有動態加載的情況下編譯的。你最好的選擇是用動態加載重建它。 – 2012-04-13 16:25:59

+0

@JonathanLeffler,是否有一個開關,專門告訴它動態或靜態? – 2012-04-13 16:29:07

+0

似乎上面的過程應該創建一個與原始相同的'perl',但它有另外的庫鏈接進去。所以如果最初的'perl'支持的動態加載(和'perl -V:usedl'似乎表明它確實),那麼新的'perl'也應該支持動態加載。對不起,我幫不了你。 – ikegami 2012-04-13 18:06:44

回答

1

我不知道是否有這是我收集並保存的電子郵件中有用的信息,它是Perl的DBD :: Informix模塊的背景信息的一部分。

Date: Wed, 13 Aug 1997 13:02:04 -0500 (CDT) 
From: "Kent S. Gordon" [email deleted] 
Subject: Re: Easy way to force static Informix libraries with DBD:Informix 

>> "kgor" == Kent S Gordon <[email protected]> wrote: 
> Is there a easy way to create a DBD:Informix that uses static Informix 
> libraries, but dynamic system libraries for everything else. 

I have succeeded in building a perl with DBD:Informix that uses dynamic 
loading for everything except DBD:Informix and DBI. I got a runtime error of 
not being able to find the symbol of boot_DBI if DBI was also not 
statically built into perl. Here is a short discription of what I did. 

1) Built perl 5.004_2 normally. 
2) Installed perl. 
3) Built DBI statically (make static). 
4) Installed DBI (make install). This is not just the install of the perl 
    binary, since DBI.a is needed later. 
5) Changed DBD Makefile.pl to call esql -static and esql -static -libs 
    instead of esql and esql -libs. 
6) Created DBD Makefile using perl Makefile.PL. 
7) Built DBD statically (make static and make perl, etc.) 
8) The make test_static failed, due to wanting to create a dynamic object 
    (Informix.sl failed due to trying fixup a symbol) 
9) Installed with make -k install to get pass error creating Informix.sl, 
    while still installing Informix.pm (could not find a special install 
    for static perl. 
10) Installed new perl executable. It seems to work after some initial 
    test. 

Kent S. Gordon 
Senior Software Engineer 
iNetSpace Co. 
[Phone and email deleted] 

我當時注意到,由於引用了Informix.sl,Kent必須在HP-UX上構建。我認爲這裏沒有任何用處,但它是我構建靜態鏈接Perl版本的唯一額外信息。正如你所看到的,它接近15歲。

我不知道Perl 5.14.x是否仍然完全支持和測試靜態鏈接模塊?

1

不知道這是否會有很大的幫助,但你可以看看App :: Staticperl。我可以在Solaris中使用它創建DBI和DBD :: Informix,也可以在HP-UX中使用。

0

從perlxstut手冊頁

動態加載與靜載

人們普遍認爲,如果系統沒有動態加載庫的能力,你不能建立XSUBs。這是不正確的。您可以構建它們,但必須將XSUBs子例程與其餘的Perl鏈接起來,從而創建一個新的可執行文件。這種情況類似於Perl 4.

本教程仍可以在這樣的系統上使用。如果可能,XSUB構建機制將檢查系統並構建可動態加載的庫,或者靜態庫,然後選擇靜態鏈接的新可執行文件,並鏈接該靜態庫。

如果您希望構建一個可以動態加載庫的系統上的靜態鏈接可執行文件,您可以在以下所有示例中執行不帶參數的「make」命令,而是運行命令「make perl」。

如果您通過選擇生成了這樣一個靜態鏈接的可執行文件,那麼應該說「make test_static」,而不是說「make test」。在根本無法構建動態加載庫的系統上,只需說出「make test」就足夠了。

它說,如果你使用行命令'make perl',那麼你告訴它建立靜態。