Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

perl

xs

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

like image 717
Eugen Konkov Avatar asked Oct 15 '25 17:10

Eugen Konkov


1 Answers

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'
like image 161
Eugen Konkov Avatar answered Oct 18 '25 20:10

Eugen Konkov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!