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

I am trying to get a perl web search script called Perlfect search to work and for some reason it can't find DB_File installed even though I can see it installed? Has anyone ran into this issue before? I have been tryign to figure this out for 2 days now.

I have BerkeleyDB 4.7 installed. and as shown below the module path seems to be in the @INC.

DB_File test 1 failure
----------------------

[dmathis@ear dmathis]$ cat test.pl #!/usr/bin/perl -w use DB_File; [dmathis@ear dmathis]$ ./test.pl Can't load '/usr/lib64/perl5/5.8.0/x86_64-linux-thread-multi/auto/DB_F +ile/DB_File.so' for module DB_File: libdb-4.7.so: cannot open shared +object file: No such file or directory at /usr/lib64/perl5/5.8.0/x86_ +64-linux-thread-multi/XSLoader.pm line 83. at /usr/lib64/perl5/5.8.0/x86_64-linux-thread-multi/DB_File.pm line 2 +52 [dmathis@ear ircsearch]$ locate DB_File.so | grep -v dmathis; locate l +ibdb-4.7.so | grep -v dmathis /usr/lib64/perl5/5.8.0/x86_64-linux-thread-multi/auto/DB_File/DB_File. +so /usr/local/BerkeleyDB.4.7/lib/libdb-4.7.so
DB_File test 2 failure
----------------------
[dmathis@ear ircsearch]$ cat indexer.pl | head -60 | tail -31 # added program path to @INC because it fails to find ./conf.pl if # started from other directory { # block is for $1 not mantaining its value $0 =~ /(.*)(\\|\/)/; push @INC, $1 if $1; } my $db_package = ""; package AnyDBM_File; @ISA = qw(DB_File); # You may try to comment in the next line if you don't have DB_File. S +till # this is not recommended. #@ISA = qw(DB_File GDBM_File SDBM_File ODBM_File NDBM_File); foreach my $isa (@ISA) { if( eval(require $isa) ) { $db_package = $isa; last; } } if( $db_package ne 'DB_File' ) { die "*** The DB_File module was not found on your system."; } [dmathis@ear ircsearch]$ ./indexer.pl Can't locate DB_File in @INC (@INC contains: /usr/lib64/perl5/5.8.0/x8 +6_64-linux-thread-multi /usr/lib/perl5/5.8.0 /usr/lib64/perl5/site_pe +rl/5.8.0 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl/5.8. +0 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.0/x86_64- +linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/ve +ndor_perl/5.8.0 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.0 . .) +at ./indexer.pl line 47. [dmathis@ear ircsearch]$ locate DB_File.pm | grep -v dmathis /usr/lib64/perl5/5.8.0/x86_64-linux-thread-multi/DB_File.pm


After all this is over, all that will really have mattered is how we treated each other.

Replies are listed 'Best First'.
Re: Perlfect search can't locate installed module DB_File.pm.
by almut (Canon) on Jun 26, 2008 at 17:15 UTC

    Try adding the respective directory to the shared library search paths (which is independent of @INC), i.e.

    $ LD_LIBRARY_PATH=/usr/local/BerkeleyDB.4.7/lib ./test.pl

    If that works, you could either write a little wrapper to set LD_LIBRARY_PATH appropriately, or create a symlink to libdb-4.7.so from within a directory which already is on the list of lib directories searched by default (usually /usr/lib (or /usr/lib64), /usr/local/lib, etc. — in case of doubt, use strace -f -efile ./test.pl to find out which directories are being tried...)

    (See the man page ld.so(8) for details on configuring the dynamic linker/loader)

      Thanks almut, that fixed the test senario but the perl module require in the indexer.pl still fails to find the module. Any ideas?

      After all this is over, all that will really have mattered is how we treated each other.

        Either use string eval

        if( eval "require $isa" ) {

        or block eval (adding ".pm")

        eval { require "$isa.pm" } unless ($@) { ... }

        (Update: fixed my reply several times... now it should finally be ok :)