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

Greetings Monks, I'm getting this error:
Can't locate auto/GD/Image.al in @INC...
When trying to copyResized using GD. Any ideas what's wrong with my installation of GD, or if I should be barking up another tree? Cheers, K.

Replies are listed 'Best First'.
Re: Missing Image.al?
by almut (Canon) on Mar 28, 2008 at 01:06 UTC

    You haven't by any chance accidentally omitted the new when constructing an image? For example in some piece of code similar to this

    use GD; my $img = new GD::Image(100,100);

    I'm asking because if you wrote

    use GD; my $img = GD::Image(100,100);

    you'd get the very error message you're seeing

    > perl 676872.pl Can't locate auto/GD/Image.al in @INC ...

    This is because in this case a subroutine Image would be tried to be called in the GD namespace. As this subroutine doesn't exist, the call would be routed to the AutoLoader (which can't locate it either, simply because there is no such sub...)  OTOH, new GD::Image() (which could also more clearly be written as GD::Image->new() ) would call the method new in the package/namespace GD::Image, which is what you want to do.

      Thanks, I also had that problem and forgot the 'new'!
Re: Missing Image.al?
by samtregar (Abbot) on Mar 27, 2008 at 23:00 UTC
    It's broken - reinstall GD and you should be good to go. A more technical description will require more information from you - what you did, what versions, etc.

    A reasonable guess: you installed a new version of Perl and didn't reinstall GD, which is sometimes needed because GD is an XS module.

    -sam

      Actually, it is very likely not broken. That particular error message is just really bad (misleading), it puts all of the stress on the very unlikely reason (a broken installation) and doesn't even mention the very likely reason (you mispelt a method name).

      My install of GD is not broken and yet perl -MGD -e"GD->Image()" says Can't locate auto/GD/Image.al in @INC .... This is just something that has long sucked about autoload. I vaguely recall somebody hinting at improving that error message around the last time I complained about it. I also vaguely recall that the error message itself used to state the suspicion that you have a broken installation. But I still find the error message quite misleading.

      When one of my modules previously used inheritance to make use of some standard module (probably DynaLoader), I added my own AUTOLOAD routine to the module just so I could prevent that misleading error message (and the support questions it would likely produce). Since then I stopped using inheritance to get access to a single subroutine from standard modules like Exporter and DynaLoader.

      - tye        

        Yup, sounds right to me. I'm surprised I didn't think of that - I'm sure this has bitten me a few times too.

        -sam

      Tried reinstalling, to no avail. I'm using Active-Perl 5.10 and GD 2.35. Cheers, K.