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

Hello Monks,

My MacBookPro, me writing/running years of Perl stuff, died a terrible death, and $$$ to repair it are in short supply, so...

I am running Windows 10 on my better half's cute little Lenovo ThinkPad, and for Perl, ubuntu in Windows Subsystem for Linux. WSL is very cool, and so far so good. Moved a bunch of stuff over from my backups using Paragon HFS+, also very cool. However, getting BerkeleyDB installed is proving to be a bitch, just as it was in macOS. I've tried cpan, cpanm and HomeBrew to build BerkeleyDB.pm from BerkeleyDB-0.64.tar.gz but the build log consistently reports:

BerkeleyDB.xs:76:10: fatal error: db.h: No such file or directory 76 | #include <db.h>

Thinking it might be a ubuntu library issue, I've tried searching apt-cache for a db dev library, but nothing seems appropriate, unless I'm just missing something.

So, that tar ball, presumably from Oracle, is missing a critical header. I have searched Google high and low for a suitable header, and I suspect it is a header that pulls in other platform specific headers as needed, so getting the right one is critical. I use BerkeleyDB and tied hashes extensively, so I will lose much good work if I can't resolve this build issue.

Perhaps a polite note to the maintainer of that bundle would not be amiss, if I knew where to send it?

Thanks in advance, and any suggestions where and how to get that header and fix the build will be greatly appreciated.

Replies are listed 'Best First'.
Re: Installing BerkeleyDB in WSL/ubuntu
by marto (Cardinal) on Jan 31, 2021 at 23:01 UTC

      Thank you marto (+++),

      That link, though outdated, really helped. I found a 4-year old tutorial for installing libdb4.8-dev and libdb4.8++-dev, so I searched apt-cache and found libdb5.3-dev and libdb5.3++-dev. After installing both of these building Perl's BerkeleyDB and MLDBM with cpanm both worked perfectly; no errors. My biased observation; my bad. I should have read the README :-( When all else fails, read the documentation. Without Monks to fall back on, I would be up the proverbial creek without a paddle. I have Geodesic great circle calculators written in C and Perl that use Berkeley DB I am very proud of and don't wish to lose. One uses spherical calculus, as in:

      greatCircleBDB.pl* mapHashBDB 'Renton, WA' 'Redmond, OR'

      Calculate great-circle distance between: Renton, WA: 0.828799, -2.132710 and, Redmond, OR: 0.772381, -2.114462. Geodesics in radians. GCD (Spherical Law of Cosines) between Renton, WA and Redmond, OR: 368 +.430 km, (198.936 NM). GCD (Haversine) between Renton, WA and Redmond, OR: 368.430 km, (198.936 NM). GCD (Vincenty inverse formula) between Renton, WA and Redmond, OR: 368 +.336 km, (198.885 NM).

      I can now continue exploring using Perl to solve advanced math problems, my hobby now that I'm retired (math minor from UofI, 1971. Crypto next up...

      Thanks again.

        Glad that worked for you, or at least gave a pointer in the right direction. That link is for the current README file, though that part has probably been the same for ages. Had it not been so late (my time) when posting I'd have suggested doing sudo apt install libberkeleydb-perl from the Ubuntu command prompt (within WSL) to install the perl module for the system perl from the Ubuntu repos.

      Further up in prerequisites
      * Berkeley DB Version 2.6.4 or greater The official web site for Berkeley DB is http://www.oracle.com/technology/products/berkeley-db/db/index +.html The latest version of Berkeley DB is always available there. It is recommended that you use the most recent version available.