3

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

Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158
  • Why do you want to do this? Have you run the module tests? If you are working with the system perl but are unable to install modules in the system library locations then you should install them under your `users` directory and add to `@INC`. – Borodin Jan 16 '18 at 13:22
  • 1
    @Borodin: I study `XS`. I create boilerplate, make changes to `.xs`, build, run code and see what happen: `./Build && perl -Iblib/lib -Iblib/arch -MModule -e 'Module::Test()'` (earlier I make changes, build, install, run code) – Eugen Konkov Jan 16 '18 at 14:45

1 Answers1

2

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'
Community
  • 1
  • 1
Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158
  • 2
    This is a dreadful hack. And why do you have a `blib` directory in your current working directory? You ***must not*** use the files in `blib`. They are *temporary files* created by `MakeMaker` in an intermediate stage of a module build. They are liable to be deleted at any time. If you want to do this as a temporary measure then use the [`blib`](https://metacpan.org/pod/blib) module with `-Mblib` on the command line, but it is ***not*** a permanent solution. – Borodin Jan 16 '18 at 13:25
  • Please tag your comments with, for example `@Borodin` so that I am notified if a message is waiting for me. – Borodin Jan 16 '18 at 15:06
  • It is not meant to be a solution. ***Don't use software from `blib`*** it may well vanish one day because it is just a partial build remnant. – Borodin Jan 16 '18 at 15:07
  • @Borodin: See comment at question why I need this. – Eugen Konkov Jan 16 '18 at 18:23