开发者

What's going on here with my freshly compiled perl?

I compiled perl with a relocatable @INC as follows:

$ sh Configure -des -D prefix=~/perl -Duserelocatableinc

After I set up my path etc I get the following:

$ perl -e 'use strict; print "ok"'
Can't locate strict.pm in @INC (@INC contains: ../lib/site_perl/5.12.4/darwin-2level ../lib/site_perl/5.12.4 ../lib/5.12.4/darwin-2level ../lib/5.12.4 .) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.

If I do this though, everything it's all OK?

$ `which perl` -e 'use strict; print "ok"'

Have I done something wrong? This is on OS X.

Here's the output for perl -V:

$ perl -V
Can't locate Config.pm in @INC (@INC contains:     ../lib/site_perl/5.12.4/darwin-2level ../lib/site_perl/5.12.4     ../lib/5.12.4/darwin-2level ../lib/5.12.4 .).
BEGIN failed--compilation aborted.

$ `which perl` -V
Summary of my perl5 (revision 5 version 12 subversion 4) configuration:

  Platform:
    osname=darwin, osvers=10.8.0, archname=darwin-2level
    uname='darwin fenchurch-2.local 10.8.0 darwin kernel version 10.8.0: tue     jun 7 16:33:36 pdt 2011; root:xnu-1504.15.3~1release_i386 i386 '
    config_args='-des -D prefix=/Users/kd/perl -Duserelocatableinc'
    hint=recommended, 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 ='-fno-common -DPERL_DARWIN -no-cpp-precomp     -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include     -I/opt/local/include',
    optimize='-O3',
    cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp     -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include     -I/opt/local/include'
    ccversion='', gccversion='4.2.1 (Apple Inc. build 5666) (dot 3)',     gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    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='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector     -L/usr/local/lib -L/opt/local/lib'
    libpth=/usr/local/lib /opt/local/lib /usr/lib
    libs=-lgdbm -ldbm -ldl -lm -lutil -lc
    perllibs=-ldl -lm -lutil -lc
    libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup     -L/usr/local/lib -L/opt/local/lib -fstack-protector'


Characteristics of this binary (from libperl): 
  Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP USE_64_BIT_ALL
                        USE_64_BIT_INT USE_LARGE_FILES USE_PERLIO
                        USE_PERL_ATOF
  Built under darwin
  Compiled at Jul 16 2011 15:44:19
  %ENV:
    PERL_MM_USE_DEFAULT="1"
  @INC:
    /Users/kd/perl/lib/site_perl/5.12.4/darwin-2level
    /Users/kd/perl/lib/site_perl/5.12.4开发者_运维问答
    /Users/kd/perl/lib/5.12.4/darwin-2level
    /Users/kd/perl/lib/5.12.4
    .


OK, found a bug report:

http://www.nntp.perl.org/group/perl.perl5.porters/2011/03/msg169818.html


Do you get anything for perl -V? Using the capital V shows the version and the compilation options, including the @INC directories. Ensure those directories are where the modules are.

Also note that in prefix, you're nominating the directory for installation, so perl should be in ~/perl/bin/perl. Is that the perl you are running? I wouldn't expect which to find that unless you have already adjusted your PATH.


I can't imagine a scenario where you would rather precompile the Perl interpreter with a new @INC path rather than just setting it into the environment or establishing it in the Perl script itself.

Compiling a new lib path into Perl seems excessive and fragile.

I think you're much better off passing it as an argument:

PERL5LIB="/my/new/path":$PERL5LIB /path/to/my/script.pl

or inside the script itself, since you already know the path required:

push(@INC, "/my/new/path");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜