develooper Front page | perl.perl5.porters | Postings from June 2018

DB_File woes on MacOS

Thread Next
paul.marquess via perl5-porters
June 24, 2018 20:16
DB_File woes on MacOS
Message ID:
I've had a flurry of emails and RT tickets recently on DB_File that can be
summarised as "MacOS is shipping with a bad version of the Berkeley DB
library that blows up in the DB_File test harness."


Danny Thomas has suggested the patch below to Makefile.PL for DB_File to
catch the problem early on in the build.


I've no problem in principle with catching this error early on in the build
as long as it doesn't cause more problems than it solves.


Didn't know (or have long forgotten) that ExtUtils::MakeMaker returned
LD_RUN_PATH. In fact, I don't see it mentioned in the main
ExtUtils::MakeMaker man page. I see LD_RUN_PATH mentioned in
ExtUtils::Liblist. It says this about Win32 (and VMS) support for


     LDLOADLIBS and EXTRALIBS are always identical under Win32, 

     and BSLOADLIBS and LD_RUN_PATH are always empty (this may change in


Means the patch would need to ignore (at least) Win32 and VMS.


Does anyone have a module that does something similar or comments on the
approach? I'm keen not to break the build for other platforms




diff -ur DB_File-1.841.orig/Makefile.PL DB_File-1.841/Makefile.PL

--- DB_File-1.841.orig/Makefile.PL            2018-04-02 20:16:07.000000000

+++ DB_File-1.841/Makefile.PL  2018-06-24 17:16:06.999773077 +1000

@@ -45,7 +45,7 @@

# building this module with the perl source distribution.

my $CORE = $ENV{PERL_CORE} ? '' : '-D_NOT_CORE';


+my $MM = WriteMakefile(

               NAME                   => 'DB_File',

               LIBS                        => ["-L${LIB_DIR} $LIBS"],

               INC                         => "-I$INC_DIR",

@@ -79,6 +79,35 @@



+# printf "%s : '%s'\n", $_, $MM->{$_}//'<undef>' for qw(EXTRALIBS

+unless ($MM->{LD_RUN_PATH}) {

+    print "Doesn't seem like ExtUtils::MakeMaker found libdb,\n";

+    print "so you should have seen:\n";

+    print "  Warning (mostly harmless): No library found for -ldb\n";

+    print "which is actually not so harmless.\n";

+    if ($^O eq 'darwin') {

+        print "The BerkeleyDB library doesn't seem to have been included
with macOS+XCode\n";

+        print "since at least OSX 10.9, even though a /usr/include/db.h is

+        print "by XCode's Command_Line_Tools.\n";

+        print "NB the system perl does include a working DB_File
(statically linked libdb?):\n";

+        print "

+        print "FYI that DB_File seems buggy (in at least macOS 10.13):\n";

+        print "\n\n";

+        print "To build DB_File successfully, you'll need a libdb from
another source such\n";

+        print "as MacPorts or HomeBrew. DB_File does look under one
non-standard directory\n";

+        print "/usr/local/BerkeleyDB for {include,lib}.\n";

+        print "So a simple approach for MacPorts:\n";

+        print "  sudo port install db48\n";

+        print "  sudo mkdir /usr/local/BerkeleyDB\n";

+        print "  sudo ln -s /opt/local/lib/db48

+        print "  sudo ln -s /opt/local/include/db48

+    } else {

+        print "You may need to install the 'libdb' or 'libdb-devel' package
or port.\n";

+    }

+    exit 1;




my @names = qw(



Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About