perlxs

How to use a module from the local library without installing it?


I have an XS module. After building it with ./Build the Module.so is placed into blib/arch/auto/XS directory.

In my Module.pm I have:

require XSLoader;
XSLoader::load( 'Module', $VERSION );

And I run program as:

$ perl -Iblib/lib -MModule -e 'my $x; $x=1'

or

$ perl -Iblib -MModule -e 'my $x; $x=1'

In both cases the module installed to a system earlier is used.

Which option I should use to run code with Module.so from blib/arch/auto?

UPD
I try to use module from blib because I have not need to install it during developing and experiments with XS


Solution

  • I pry into xstut:

    perl -MExtUtils::Command::MM -e "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
    

    And then here:

     test_harness($verbose, @test_libs);
    

    Runs the tests on @ARGV via Test::Harness passing through the $verbose flag. Any @test_libs will be unshifted onto the test's @INC.

    So I should include both paths into @INC:

    $ perl -Iblib/lib -Iblib/arch -MModule -e 'my $x; $x=1'
    

    UPD
    As @Borodin said, the better solution is to use blib module:

    $ perl -Mblib -MModule -e 'my $x; $x=1'