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

I installed the Tk modules off of CPAN last night. Everything seemed to work out fine, but running perl -e 'use Tk;' results in the following error:

Can't locate loadable object for module Tk::Event in @INC

However, @INC contains /usr/local/lib/site_perl/i386-linux/, and the file /usr/local/lib/site_perl/i386-linux/Tk/Event.pm exists (and I have read/write access to the file.)

If any monk out there had any idea why this isn't working, I'd be truly grateful. I'm using perl 5.6.0, if that matters at all.

Replies are listed 'Best First'.
Re: Coercing Tk
by chipmunk (Parson) on Dec 23, 2000 at 22:13 UTC
    The "Can't locate loadable object for module..." error means that a compiled file associated with the module couldn't be found. For example, I can get this error by moving the .so dynamic library file for a module. These files should be in an auto/ directory somewhere in @INC.

    If the module itself were missing, you would get the error "Can't locate Tk/Event.pm in @INC...".

    You've got the .pm file, but not the associated file(s), so the question is, how did you install the Tk modules? Did you follow the instructions in the README file?

      I installed Tk by doing a perl -MCPAN -e "shell" and typing install Tk at the prompt.

      However, with your help, I got it to work... I didn't have access to the auto/ directory; after chmod 755'ing it, the use Tk directive works fine. Thanks.

Re: Coercing Tk
by mrmick (Curate) on Dec 24, 2000 at 19:52 UTC
    This is just a guess but since you haven't actually 'created' a Tk object with 'new' , Perl may be complaining that there's no object with which to associate Tk::Event.

    Of course, if I'm wrong, we'll hear about it soon from the monks more experienced with OO and with the Tk modules.

    Mick
      I'm afraid that your guess is wrong. As I said in my earlier response, "Can't locate loadable object..." means that a dynamic library file associated with the module couldn't be found. This error is unrelated to a module being object-oriented.

      In this case, the loadable object could not be found because the auto/ directory, in which it was installed, did not have the expected permissions. More often, the error occurs because a module has been "installed" by a user who just copies the .pm files into an @INC directory, instead of using `make; make test; make install`.