I have multiple versions of Perl installed; each under a different directory. e.g. C:\Perl\5.x.y. I switch between them in a shell by setting PERL5LIB and altering my PATH so that only one version is visible at a time. Normally, this works fine, but when trying to run the version of pp (PAR::Packer) installed under 5.10.1 I have problems loading XS components. parll2nc.exe complains:
This application has failed to start because perl512.dll was not found…
I set PERL_DL_DEBUG and see the following when DynaLoader initializes:
DynaLoader.pm loaded (C:/Perl/5.10.1/site/lib C:/Perl/5.12.1/lib ., \lib)
The stuff before the comma is @INC. The first entry is correct, the second is not. I can’t figure out how DynaLoader is getting a 5.12 lib path as running perl directly shows what I would expect:
C:\>perl -e "print join ' ', @INC"
C:/Perl/5.10.1/site/lib C:/Perl/5.10.1/lib .
How is DynaLoader picking up the wrong path and how do I prevent it from doing so?
I figured it out. The problem is caused by an interaction of several things:
C:\>fooinstead ofC:\>foo.plpputility does not have a batch file wrapper created withpl2bat. (I’m not sure why.)The net result is that when I ran
pp @myconfigit effectively did this:i.e. it ran the version of pp.pl in my path using the version of perl associated with *.pl files, not the version of perl in my PATH. Thus the mix of libs in
@INCbetween what came from the executable (C:\Perl\5.12.1\lib) and what came from the PERL5LIB environment variable (C:\Perl\5.10.1\site\lib).The solution is to either run
ppasperl pp.plor (better, because you don’t have to remember anything) to create a batch wrapper. Assuming that .BAT is in PATHEXT before .PL, when you typeppWindows will runpp.batinstead ofpp.pl, andpp.batinvokesperl(using the version in your path).sigh