سؤال

I know documentation is lacking for this mysterious module, but Im running Strawberry Perl and would be happy just with being able to install it. I typically run something like the following from the command line to get a module:

cpan WWW::Selenium

To get WWW::Selenium, for example. Yet when I run

cpan Lucene

I get all this and, as I've never seen this before, I point the finger at Windows for lack of a better lead:

C:\Users\PHJohnson\Desktop>cpan Lucene
CPAN: CPAN::SQLite loaded ok (v0.202)
Database was generated on Mon, 25 Jun 2012 18:28:43 GMT
Running install for module 'Lucene'
Running make for T/TB/TBUSCH/Lucene-0.18.tar.gz
CPAN: Digest::SHA loaded ok (v5.63)
CPAN: Compress::Zlib loaded ok (v2.042)
Checksum for C:\strawberry\cpan\sources\authors\id\T\TB\TBUSCH\Lucene-0.18.tar.gz ok
CPAN: Archive::Tar loaded ok (v1.80)
CPAN: File::Temp loaded ok (v0.22)
CPAN: Parse::CPAN::Meta loaded ok (v1.4401)
CPAN: CPAN::Meta loaded ok (v2.112621)

CPAN.pm: Building T/TB/TBUSCH/Lucene-0.18.tar.gz

couldn't find clucene config file at Makefile.PL line 34.
Warning: No success on command[C:\strawberry\perl\bin\perl.exe Makefile.PL]
TBUSCH/Lucene-0.18.tar.gz
C:\strawberry\perl\bin\perl.exe Makefile.PL -- NOT OK
Running make test
  Make had some problems, won't test
Running make install
  Make had some problems, won't install
Could not read metadata file. Falling back to other methods to determine prerequisites

C:\Users\PHJohnson\Desktop>

I wonder, how can I remedy this - can I get the Lucene library on Windows?

هل كانت مفيدة؟

المحلول

See, some Perl modules are just wrappers around some libraries and/or system tools, allowing to use them naturally within Perl program (using the familiar syntax constructs, etc.) Lucene is built the same way: it's a wrapper around CLucene indexing library.

So you have (as quite often with Perl) two options: either try to build CLucene from the source (I said 'try', because I really don't know whether it will work on Windows or not) - or look for similar solutions, like KinoSearch (or its fork, KinoSearch1 - both are rated quite nice by reviewers) and Plucene. The latter is actually a Perl port of the Lucene search engine, not a wrapper of any kind.

نصائح أخرى

Looking at the Makefile.PL, the module is not designed to work under Windows, if you look at the Makefile.PL under "C:\Strawberry\cpan\build\" (on my machine), you should see something like this on lines ~8:

## Hash that specifies for each OS all possible directories to look
## for CLucene/clucene-config.h
my $rh_include_dirs = {
     "linux"   => ["/usr/include",       "/usr/lib"], 
     "freebsd" => ["/usr/local/include", "/usr/local/lib"], 
     "darwin"  => ["/usr/local/include", "/usr/local/lib"],
};

you could try to add another entry with the path where you have Lucene installed in windows.

my $rh_include_dirs = {
     "linux"   => ["/usr/include",       "/usr/lib"], 
     "freebsd" => ["/usr/local/include", "/usr/local/lib"], 
     "darwin"  => ["/usr/local/include", "/usr/local/lib"],
     "MSWin32" => ["path to your lucene install"],
};

After updating the file and saving it, you should be able to do a regular perl Makefile.PL and then the usual make and make install (or nmake on windows). The Makefile.PL script will generate the necessary files for make to build and install the package.

I don't have Lucene, so I can't try it out tho...

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top