suhaslimaye has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I have compiled perl 5.8.8 on windows XP with Microsoft visual studio 8 2005 Pro. edition. Compilation is successful. Key points are: compiled perl with thread support off, perlio=off, largefilesupport=off. Now with this new perl, I have compiled our module <Abcd> to generated Abcd.dll ( perl58.lib is linked with Abcd ). Abcd.pm is copied to perl\lib directory. and Abcd.dll ... in site. When I use our module in perl script, i.e perl script a.pl use Abcd; I got following error .... Can't load '....perl5/site/lib/MSWin32-x86/auto /Abcd/Abcd.dll' for module Abcd: load_file: This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem at .../perl5 /lib/MSWin32-x86/DynaLoader.pm line 229. at a.pl line 3 Compilation failed in require at a.pl line 3. at a.pl line 3 main::BEGIN() called at .../lib/Abcd.pm line 3 eval {...} called at BEGIN failed--compilation aborted at a.pl line 3. When I debugged, I found that, in Abcd.pm, the statement bootstrap Abcd $Version; fails to load Abcd.dll. I donot know what's wrong I have done? Because, Same module Abcd works with perl 5.6.1 non-threaded perl for last 2 years.

Replies are listed 'Best First'.
Re: Perl 5.8.8 build on WinXP
by BrowserUk (Patriarch) on Sep 15, 2008 at 08:08 UTC

    The essential rule is:

    If the .pm file lives in the path /yourperl/site/lib/your/module.pm

    Then the associated .dll needs to be in /yourperl/site/lib/auto/your/module.dll


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      Then the associated .dll needs to be in /yourperl/site/lib/auto/your/module.dll

      That's what I thought, too ... until I discovered recently that the dll can go in, for example, /yourperl/site/lib/module.dll. The 'auto' is not needed, and the 'your' is not needed either. I've just double checked this by relocating perl/site/5.10.0/lib/auto/Math/GMP/GMP.dll to perl/site/5.10.0/lib/GMP.dll. There may be other alternative locations, too. I haven't checked.

      Cheers,
      Rob

        True, but as this extract from Dynaloader.pm shows, it looks in site/lib/auto/module first:

        foreach (@INC) { chop($_ = VMS::Filespec::unixpath($_)) if $Is_VMS; my $dir; if ($Is_MacOS) { my $path = $_; if ($Mac_FS && ! -d $path) { $path = Mac::FileSpec::Unixish::nativize($path); } $path .= ":" unless /:$/; $dir = "${path}auto:$modpname"; } else { $dir = "$_/auto/$modpname"; } next unless -d $dir; # skip over uninteresting directories # check for common cases to avoid autoload of dl_findfile my $try = $Is_MacOS ? "$dir:$modfname.$dl_dlext" : "$dir/$modfname +.$dl_dlext"; last if $file = ($do_expand) ? dl_expandspec($try) : ((-f $try) && + $try); # no luck here, save dir for possible later dl_findfile search push @dirs, $dir; }

        After that, it basically goes off on a mind-blowingly slow and complicated tour of every directory in @INC and a few other places. The question is: why? What does this 'flexibily' buy anyone? It's just more complexity for no gain.

        The danger of omitting the your is that Simple.dll from the XS version of XML::Simple overwrites Simple.dll from the XS version of CGI::Simple. Omitting the auto compounds the problem.

        Define a rule, document it and stick to it. And then, when the dll isn't found the module can report site/lib/auto/your/module.dll not found. Currently, they cannot do that because they would have to say:

        Couldn't find Module.dll in site/lib/auto/your, or site/lib/auto or si +te/lib or site/lib/some/other/module/You/Used or site/lib/some/Other/ +Random/Place/WeT/hought/To/Try/ ...

        Sigh! If only we could go back in time.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re: Perl 5.8.8 build on WinXP
by Erez (Priest) on Sep 15, 2008 at 05:45 UTC

    I would suggest formatting your output with <code></code> tags. That way it will make things better on the eyes of the reader.

    Other than that, concensus seems to be in favour of using a Windows Perl distribution (ActiveState/Strawberry ) rather than building it yourself.

    Stop saying 'script'. Stop saying 'line-noise'.
    We have nothing to lose but our metaphors.

Re: Perl 5.8.8 build on WinXP
by Anonymous Monk on Sep 15, 2008 at 07:40 UTC
    Abcd.pm is copied to perl\lib directory. and Abcd.dll ... in site.
    That is wrong. Do not do that. Installation goes as
    perl Makefile.PL make make test make install UNINST=1
    and everything (including Abcd.pm and Abcd.dll) ends up in right spots.

    make is whatever is reported by 'perl -V:make'

    How to make a CPAN Module Distribution

      . Installation goes as ...

      Which is all fine and dandy if you can work out what combination of magical incantations and curses are required to pursuade EU::MM to construct a makefile and build environment that works for the requirements of your DLL.

      But that's like trying to say "left hand down a bit" to the driver of a truck, by using your mobile phone to tap out morse code to your mother, which she relays to the driver using semaphore flags. Possible, but slow, labourious, with huge latency and frustrating in the extreme.

      If the OP obviously has their development environment for building this DLL already worked and working. Expecting them to move that into the arcane blib structure just so that they can use and nested pile of stinking OO to construct a 100 times over-elaborate makefile, so that they can use nmake to copy the file to the appropriate destination is stupid.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        I don't think its stupid. If anything, it will show you how copying the pm/dll to the right spots is done. If you don't know already know, then you shouldn't be doing it that way.
Re: Perl 5.8.8 build on WinXP
by syphilis (Archbishop) on Sep 15, 2008 at 18:59 UTC
    I found that, in Abcd.pm, the statement bootstrap Abcd $Version; fails to load Abcd.dll

    Could it be that, instead of bootstrap Abcd $Version; you should have bootstrap Abcd $VERSION;. The usual convention is to assign the version number to $VERSION, but if you have, in fact, assigned it to $Version, then I guess bootstrap Abcd $Version; should work.

    Cheers,
    Rob