1

I'm trying to install a program which has various perl dependencies. One of the perl dependencies (BerkeleyDB) fails during install. I know very little about perl. Is there a way for me (as a user) to solve this? Is there a SPAN command to try earlier versions?

cpan[49]> install BerkeleyDB
Running install for module 'BerkeleyDB'
Fetching with HTTP::Tiny:
https://cpan.org/authors/id/P/PM/PMQS/BerkeleyDB-0.65.tar.gz
Checksum for /root/.local/share/.cpan/sources/authors/id/P/PM/PMQS/BerkeleyDB-0.65.tar.gz ok
Configuring P/PM/PMQS/BerkeleyDB-0.65.tar.gz with Makefile.PL
Parsing config.in...
Looks Good.
Checking if your kit is complete...
Looks good
Warning (mostly harmless): No library found for -ldb
Generating a Unix-style Makefile
Writing Makefile for BerkeleyDB
Writing MYMETA.yml and MYMETA.json
  PMQS/BerkeleyDB-0.65.tar.gz
  /usr/bin/perl Makefile.PL -- OK
Running make for P/PM/PMQS/BerkeleyDB-0.65.tar.gz
cp BerkeleyDB/Hash.pm blib/lib/BerkeleyDB/Hash.pm
cp scan.pl blib/lib/scan.pl
cp BerkeleyDB.pod blib/lib/BerkeleyDB.pod
cp mkconsts.pl blib/lib/mkconsts.pl
cp BerkeleyDB/Btree.pm blib/lib/BerkeleyDB/Btree.pm
cp BerkeleyDB.pm blib/lib/BerkeleyDB.pm
Running Mkbootstrap for BerkeleyDB ()
chmod 644 "BerkeleyDB.bs"
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- BerkeleyDB.bs blib/arch/auto/BerkeleyDB/BerkeleyDB.bs 644
"/usr/bin/perl" "/usr/share/perl5/vendor_perl/ExtUtils/xsubpp" -noprototypes -typemap '/usr/share/perl5/ExtUtils/typemap' -typemap '/root/.local/share/.cpan/build/BerkeleyDB-0.65-0/typemap'  BerkeleyDB.xs > BerkeleyDB.xsc
Warning: Found a 'CODE' section which seems to be using 'RETVAL' but no 'OUTPUT' section. in BerkeleyDB.xs, line 5936
Warning: Found a 'CODE' section which seems to be using 'RETVAL' but no 'OUTPUT' section. in BerkeleyDB.xs, line 5964
mv BerkeleyDB.xsc BerkeleyDB.c
gcc -c  -I/usr/local/BerkeleyDB/include -D_REENTRANT -D_GNU_SOURCE -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fwrapv -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -g   -DVERSION=\"0.65\" -DXS_VERSION=\"0.65\" -fPIC "-I/usr/lib64/perl5/CORE"   BerkeleyDB.c
BerkeleyDB.xs:76:10: fatal error: db.h: No such file or directory
   76 | #include <db.h>
      |          ^~~~~~
compilation terminated.
make: *** [Makefile:349: BerkeleyDB.o] Error 1
  PMQS/BerkeleyDB-0.65.tar.gz
  /usr/bin/make -- NOT OK
Failed during this command:
 PMQS/BerkeleyDB-0.65.tar.gz                  : make NO

1 Answer 1

2

If you look at the output, you'll notice the line:

BerkeleyDB.xs:76:10: fatal error: db.h: No such file or directory

The build because it is missing that development header and most likely, the package that provides it.

You haven't stated what OS your are using but in Fedora, RHEL, Alma, Rocky, etc you can see what provides the file with the following commands:

yum provides */db.h

dnf provides */db.h

This one is rather direct as it will return libdb-devel-5.3.28-53.el9.x86_64 : C development files for the Berkeley DB library which is clearly what you need.

Debian, Ubuntu, etc are a bit trickier.

You can use apt-file search db.h which will return any packages with that string and then grep through it but you'd have to know what you are looking for. A better option is to go to https://packages.ubuntu.com and search for packages containing the file db.h. You'll see the package name libdb5.3-dev and using apt show libdb5.3-dev will return the following lines which make it rather obvious.

Description: Berkeley v5.3 Database Libraries [development]
 This is the development package which contains headers and static
 libraries for the Berkeley v5.3 database library.

The file is also most likely located at /usr/include/db.h so you can also use

apt-file search /usr/include/db.h

Which will return

libdb5.3-dev: /usr/include/db.h

Afterwards, install the package and the installation via cpan will work.

7
  • Using AlmaLinux 9. I didn't realize perl modules could have c dependencies. Missing package was libdb-devel
    – TSG
    Commented Aug 5, 2023 at 1:34
  • @TSG CPAN compiles Perl modules from their source code using a Makefile and the system compilation tools file which in this case, is GCC so C and C++ headers and libraries are required. Commented Aug 5, 2023 at 1:42
  • Most perl modules are pure perl, they don't require header or library files from C or other languages. Some do, particularly those that are wrappers around existing libs (like berkeley db) or those which have compiled C components for speed. These often have XS in the name, e.g. Text::CSV_XS - see perlxs and Getting started with XS for more info.
    – cas
    Commented Aug 6, 2023 at 8:45
  • BTW, the BerkeleyDB module is already packaged for Debian/Ubuntu/Mint etc (in libberkeleydb-perl) and RHEL/Centos/Rocky/Alma/etc (in perl-BerkeleyDB). Probably for other distros too.
    – cas
    Commented Aug 6, 2023 at 8:46
  • @cas I understand that and while I can't edit the comment, to be clear, in this case because one was trying to compile one from source which does require headers and libraries, that is what's going on. You are correct in that he could have installed it via a package but perhaps there is a reason that the one via CPAN was needed. Commented Aug 6, 2023 at 12:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .