Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BerkeleyDB fails to build on MacOS 14.4.1 (Sonoma) with perl v5.38.2 and berkeley-db@5 (5.3.28_1) #11

Open
mattmartini opened this issue May 27, 2024 · 2 comments
Assignees

Comments

@mattmartini
Copy link

make fails with this error:

BerkeleyDB.xs:82:2: error: db.h is from Berkeley DB 1.x - need at least Berkeley DB 2.6.4
#error db.h is from Berkeley DB 1.x - need at least Berkeley DB 2.6.4
(see below for full make output)

However, I have BerkleyDB v5.3.28_1 installed via homebrew. (see below for brew info)

It seems that this version of BerkeleyDB is too new for the module.

brew suggests setting LDFLAGS and CPPFLAGS like this:

export LDFLAGS="-L/opt/homebrew/opt/berkeley-db@5/lib"
export CPPFLAGS="-I/opt/homebrew/opt/berkeley-db@5/include"

Setting these do not change the error message.

Additionally, brew suggests changing $PATH to put the berkeley-db bin first as:

export PATH="/opt/homebrew/opt/berkeley-db@5/bin:$PATH"

This also had no effect on the make.

make output:

Skip blib/lib/BerkeleyDB/Hash.pm (unchanged)
Skip blib/lib/BerkeleyDB/Btree.pm (unchanged)
Skip blib/lib/mkconsts.pl (unchanged)
Skip blib/lib/scan.pl (unchanged)
Skip blib/lib/BerkeleyDB.pm (unchanged)
Skip blib/lib/BerkeleyDB.pod (unchanged)
Running Mkbootstrap for BerkeleyDB ()
chmod 644 "BerkeleyDB.bs"
"/opt/homebrew/Cellar/perl/5.38.2_1/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- BerkeleyDB.bs blib/arch/auto/BerkeleyDB/BerkeleyDB.bs 644
cc -c  -I/usr/local/BerkeleyDB/include -fno-common -DPERL_DARWIN -mmacosx-version-min=14.2 -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong -Wno-error=implicit-function-declaration -O3   -DVERSION=\"0.65\" -DXS_VERSION=\"0.65\"  "-I/opt/homebrew/opt/perl/lib/perl5/5.38/darwin-thread-multi-2level/CORE"   BerkeleyDB.c
BerkeleyDB.xs:82:2: error: db.h is from Berkeley DB 1.x - need at least Berkeley DB 2.6.4
#error db.h is from Berkeley DB 1.x - need at least Berkeley DB 2.6.4
 ^
BerkeleyDB.xs:270:2: error: unknown type name 'DB_ENV'
        DB_ENV *        Env ;
        ^
BerkeleyDB.xs:305:9: error: unknown type name 'DB_INFO'
        DB_INFO *       info ;
        ^
BerkeleyDB.xs:306:9: error: unknown type name 'DBC'
        DBC *           cursor ;
        ^
BerkeleyDB.xs:307:2: error: type name requires a specifier or qualifier
        DB_TXN *        txn ;
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/db.h:93:17: note: expanded from macro 'DB_TXN'
#define DB_TXN          0x80000000      /* Do transactions. */
                        ^
BerkeleyDB.xs:307:2: error: expected member name or ';' after declaration specifiers
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/db.h:93:17: note: expanded from macro 'DB_TXN'
#define DB_TXN          0x80000000      /* Do transactions. */
                        ^
BerkeleyDB.xs:306:26: error: expected ';' at end of declaration list
        DBC *           cursor ;
                                ^
                                ;
BerkeleyDB.xs:348:9: error: unknown type name 'DB_INFO'
        DB_INFO *       info ;
        ^
BerkeleyDB.xs:349:9: error: unknown type name 'DBC'
        DBC *           cursor ;
        ^
BerkeleyDB.xs:350:2: error: type name requires a specifier or qualifier
        DB_TXN *        txn ;
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/db.h:93:17: note: expanded from macro 'DB_TXN'
#define DB_TXN          0x80000000      /* Do transactions. */
                        ^
BerkeleyDB.xs:350:2: error: expected member name or ';' after declaration specifiers
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/db.h:93:17: note: expanded from macro 'DB_TXN'
#define DB_TXN          0x80000000      /* Do transactions. */
                        ^
BerkeleyDB.xs:349:26: error: expected ';' at end of declaration list
        DBC *           cursor ;
                                ^
                                ;
BerkeleyDB.xs:394:2: error: type name requires a specifier or qualifier
        DB_TXN *        txn ;
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/db.h:93:17: note: expanded from macro 'DB_TXN'
#define DB_TXN          0x80000000      /* Do transactions. */
                        ^
BerkeleyDB.xs:394:2: error: expected member name or ';' after declaration specifiers
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/db.h:93:17: note: expanded from macro 'DB_TXN'
#define DB_TXN          0x80000000      /* Do transactions. */
                        ^
BerkeleyDB.xs:393:15: error: expected ';' at end of declaration list
        int             Status ;
                                ^
                                ;
BerkeleyDB.xs:733:5: error: unknown type name 'db_recno_t'; did you mean 'recno_t'?
    db_recno_t  x_Value;
    ^~~~~~~~~~
    recno_t
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/db.h:54:19: note: 'recno_t' declared here
typedef u_int32_t       recno_t;
                        ^
BerkeleyDB.xs:734:5: error: unknown type name 'db_recno_t'; did you mean 'recno_t'?
    db_recno_t  x_zero;
    ^~~~~~~~~~
    recno_t
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/db.h:54:19: note: 'recno_t' declared here
typedef u_int32_t       recno_t;
                        ^
BerkeleyDB.xs:877:10: warning: call to undeclared function 'txn_abort'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
                txn_abort(tid->txn);
                ^
BerkeleyDB.xs:877:25: error: no member named 'txn' in 'struct (unnamed at BerkeleyDB.xs:392:9)'
                txn_abort(tid->txn);
                          ~~~  ^
BerkeleyDB.xs:949:36: error: too many arguments to function call, expected 1, have 2
                (db->dbp->close)(db->dbp, 0) ;
                ~~~~~~~~~~~~~~~~          ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
1 warning and 20 errors generated.
make: *** [BerkeleyDB.o] Error 1

brew info berkeley-db@5:

==> berkeley-db@5: stable 5.3.28 (bottled) [keg-only]
High performance key/value database
https://www.oracle.com/database/technologies/related/berkeleydb.html
Installed
/opt/homebrew/Cellar/berkeley-db@5/5.3.28_1 (5,271 files, 86.4MB)
  Poured from bottle using the formulae.brew.sh API on 2023-12-31 at 11:39:34
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/b/berkeley-db@5.rb
License: Sleepycat
==> Caveats
berkeley-db@5 is keg-only, which means it was not symlinked into /opt/homebrew,
because this is an alternate version of another formula.

If you need to have berkeley-db@5 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/berkeley-db@5/bin:$PATH"' >> /Users/martini/.bash_profile

For compilers to find berkeley-db@5 you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/berkeley-db@5/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/berkeley-db@5/include"

perl -V:

Summary of my perl5 (revision 5 version 38 subversion 2) configuration:

  Platform:
    osname=darwin
    osvers=23.2.0
    archname=darwin-thread-multi-2level
    uname='darwin sonoma-arm64.local 23.2.0 darwin kernel version 23.2.0: wed nov 15 21:54:25 pst 2023; root:xnu-10002.61.3~2release_arm64_vmapple arm64 '
    config_args='-des -Dinstallstyle=lib/perl5 -Dinstallprefix=/opt/homebrew/Cellar/perl/5.38.2_1 -Dprefix=/opt/homebrew/opt/perl -Dprivlib=/opt/homebrew/opt/perl/lib/perl5/5.38 -Dsitelib=/opt/homebrew/opt/perl/lib/perl5/site_perl/5.38 -Dotherlibdirs=/opt/homebrew/lib/perl5/site_perl/5.38 -Dperlpath=/opt/homebrew/opt/perl/bin/perl -Dstartperl=#!/opt/homebrew/opt/perl/bin/perl -Dman1dir=/opt/homebrew/opt/perl/share/man/man1 -Dman3dir=/opt/homebrew/opt/perl/share/man/man3 -Duseshrplib -Duselargefiles -Dusethreads'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='cc'
    ccflags ='-fno-common -DPERL_DARWIN -mmacosx-version-min=14.2 -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong'
    optimize='-O3'
    cppflags='-fno-common -DPERL_DARWIN -mmacosx-version-min=14.2 -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong'
    ccversion=''
    gccversion='Apple LLVM 15.0.0 (clang-1500.1.0.2.5)'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=8
    longdblkind=0
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='cc'
    ldflags =' -mmacosx-version-min=14.2 -fstack-protector-strong'
    libpth=/opt/homebrew/Cellar/berkeley-db@5/5.3.28_1/lib /opt/homebrew/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib /Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk/usr/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib /usr/lib
    libs=-lgdbm -ldb
    perllibs=
    libc=
    so=dylib
    useshrplib=true
    libperl=libperl.dylib
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=bundle
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags=' -mmacosx-version-min=14.2 -bundle -undefined dynamic_lookup -fstack-protector-strong'


Characteristics of this binary (from libperl):
  Compile-time options:
    HAS_LONG_DOUBLE
    HAS_STRTOLD
    HAS_TIMES
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_HASH_FUNC_SIPHASH13
    PERL_HASH_USE_SBOX32
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_SAFE_PUTENV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
    USE_REENTRANT_API
  Built under darwin
  Compiled at Nov 28 2023 14:04:47
  %ENV:
    PERL5LIB="/usr/local/lib/site_perl:/opt/homebrew/opt/perl/lib/perl5/site_perl"
  @INC:
    /usr/local/lib/site_perl
    /opt/homebrew/opt/perl/lib/perl5/site_perl
    /opt/homebrew/opt/perl/lib/perl5/site_perl/5.38/darwin-thread-multi-2level
    /opt/homebrew/opt/perl/lib/perl5/site_perl/5.38
    /opt/homebrew/opt/perl/lib/perl5/5.38/darwin-thread-multi-2level
    /opt/homebrew/opt/perl/lib/perl5/5.38
    /opt/homebrew/lib/perl5/site_perl/5.38

uname -a:

Darwin mycomputer 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:49 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6020 arm64
@mattmartini
Copy link
Author

I was able to get the build to work by making these changes to config.in:

INCLUDE	= /opt/homebrew/opt/berkeley-db@5/include
LIB	= /opt/homebrew/opt/berkeley-db@5/lib

While I was able to infer this solution from the README file, a more explicit explanation of the error fix, or an automated solution, would be nice.

@grr
Copy link

grr commented Jun 9, 2024

This is related to #9. which was initially requested over a decade ago and is relatively easy to implement. If the author ever responded, somebody probably would have even submitted a patch...

@pmqs pmqs self-assigned this Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants