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

hello,

i cant include tha math::random library, don't you know why?

this is printed after executing a 2 line script:
D:\Work\scrabble>scrabble.pl Can't locate loadable object for module Math::Random in @INC (@INC con +tains: D:/Perl/lib D:/Perl/site/lib .) at D:\Work\scrabble\scrabble.p +l line 1 Compilation failed in require at D:\Work\scrabble\scrabble.pl line 1. BEGIN failed--compilation aborted at D:\Work\scrabble\scrabble.pl line + 1.
this is the script
use Math::Random; $random = random_uniform();
I have the random pm

20040907 Edit by ysth: change title from: can't locate object...?

Replies are listed 'Best First'.
Re: "can't locate loadable object for module" error
by fizbin (Chaplain) on Sep 07, 2004 at 14:29 UTC
    Math::Random is a perl module that comes in two halves - a .pm file and a compiled bit, which on Windows will be stored as four files: .bs, .exp, .dll, and .lib. These are generally in a subdirectory of your perl install called "auto". I suspect that you didn't install Math::Random properly on this machine, but just copied the .pm over from another machine. That's not enough - either install the module properly, or catch all the files sitting under auto/Math/Random on this first machine.

    I suspect that you may have not installed this module properly because you don't have a working C compiler on the target machine, a common issue with Windows that prevents much of the CPAN magic from working. However, if you've installed ActivePerl from the ActiveState people, then there's an easy way to install Math::Random properly: use ActiveState's ppm utility. Open a cmd box and type "ppm3". Then, at the prompt say "install Math::Random". If you get back a list of several different packages, you can install the one you want by saying "install 1". This will download a precompiled version of Math::Random from Activestate's website, with all necessary files.

    Other people also maintain ActiveState ppm repositories; you can add them too if you need a module which ActiveState hasn't got available.

    -- @/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/
Re: "can't locate loadable object for module" error
by doowah2004 (Monk) on Sep 07, 2004 at 14:15 UTC
    I just installed Math::Random via ppm:

    c:\ppm
    ppm>install math-random
    ppm>q

    Ran your two line program with no problems. Doing the same would be a good starting point.
    Let us know if this helps.


    Cameron
Re: "can't locate loadable object for module" error
by BrowserUk (Patriarch) on Sep 07, 2004 at 14:12 UTC

    Math::Random has a binary (compiled) component as well as the .pm file. It's this file (Random.dll) that it isn't finding. Did you install with PPM or CPAN.PM or just copy the .pm file?


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
Re: "can't locate loadable object for module" error
by shenme (Priest) on Sep 07, 2004 at 14:08 UTC
    Are you sure you have it installed? Are you sure you have all the pieces of the Math::Random package? How did you install it?

    I see at search.cpan.org that there is more to the package than just file Random.pm. You might not have everything, and it might not be in the right place.

Re: "can't locate loadable object for module" error
by jockel (Beadle) on Sep 07, 2004 at 13:55 UTC
    Hello Where do You have the "Math/Random.pm" file?
    Is it in your work directory (D:\Work\scrabble\) or is it
    in any of the @INC directories from the error output?
    If it's your work dir. then write

    use lib qw(.);

    before the use Math::Random; row.

    /jocke