Compile/Link error building BerkeleyDB on Windows 7 (64bit) with Perl64
Asked Answered
G

1

8

I want to use the perl BerkleyDB module on Windows, but I do not manage to do it.

I know there are a lot problems with this and I read many of the questions here on SO and also on other sources. But I found no solution for it.

For example there is: Use CPAN BerkeleyDB module on Windows 7 (64 bit) But there is no answer. There is a hint to a 64-bit patch, but the link is broken.

Environment

  • Windows 7 Professional

  • Perl 5.16

    C:\> perl -v
    
    This is perl 5, version 16, subversion 3 (v5.16.3) built for MSWin32-x64-multi-thread
    (with 1 registered patch, see perl -V for more detail)
    
    Copyright 1987-2012, Larry Wall
    
    Binary build 1603 [296746] provided by ActiveState http://www.ActiveState.com
    Built Mar 13 2013 13:31:10
    
    Perl may be copied only under the terms of either the Artistic License or the
    GNU General Public License, which may be found in the Perl 5 source kit.
    
    Complete documentation for Perl, including FAQ lists, should be found on
    this system using "man perl" or "perldoc perl".  If you have access to the
    Internet, point your browser at http://www.perl.org/, the Perl Home Page.
    
  • MinGW

    With my first attempt to install the BerkelyDB from CPAN MinGW64 (4.5.4) and dmake (4.12.20090907) was automatically installed.

    C:\>cpan 
    Set up gcc environment - gcc.exe (rubenvb-4.5.4) 4.5.4
    
  • BerkeleyDB 0.54 (Perl-Binding)

    Downloaded using cpan.

  • BerkeleyDB (Lib from Oracle)

    First I installed BerkeleyDB 6.1.19 from Oracle (using .msi). Thought that the newest version would be the best. After some problems I read the description of cpan BerkeleyDB again:

    BerkeleyDB - Perl extension for Berkeley DB version 2, 3, 4 or 5
    

    So I deinstalled it and took BerkeleyDB 5.3.28 (using .msi). But this did not work either. Then I found an article where the writer said that he successfully compiled BerkeleyDB 4.7.25 on Windows. So I took this one.

Changes and Problems

As described above I'm on BerkeleyDB library version 4.7.25, but the follwing problems also occured with the other versions.

After downloading BerkeleyDB-0.54 from CPAN I did

perl Makefile.PL
dmake

I got an error:

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

Reason: The perl module needs to know where the lib is. So I edited the config.in to

INCLUDE = C:\App\BerkeleyDB4.7.25\include
LIB = C:\App\BerkeleyDB4.7.25\lib
DBNAME = -ldb47

The filename in C:\App\BerkeleyDB4.7.25\lib is libdb47.lib. But I'm not sure what DBNAME expects. So I tried different values:

DBNAME = -llibdb47

Now running

dmake

I get

C:\Perl64\cpan\build\BerkeleyDB-0.54-rjSkdy>dmake
Skip blib\lib\BerkeleyDB.pm (unchanged)
Skip blib\lib\BerkeleyDB\Hash.pm (unchanged)
Skip blib\lib\scan.pl (unchanged)
Skip blib\lib\BerkeleyDB.pod (unchanged)
Skip blib\lib\mkconsts.pl (unchanged)
Skip blib\lib\BerkeleyDB\Btree.pm (unchanged)
C:\Perl64\site\bin\gcc.exe -c  -IC:\App\BerkeleyDB4.7.25\include        -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DWIN64 -DCONSERVATIVE -DPERL_TEXTMODE_SCRIPTS -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DHASATTRIBUTE -fno-strict-aliasing -mms-bitfields -O2        -DVERSION=\"0.54\"    -DXS_VERSION=\"0.54\" "-IC:\Perl64\lib\CORE"  BerkeleyDB.c

No errors while compiling, but then

Running Mkbootstrap for BerkeleyDB ()
C:\Perl64\bin\perl.exe -MExtUtils::Command -e chmod -- 644 BerkeleyDB.bs
C:\Perl64\site\bin\dlltool.exe --def BerkeleyDB.def --output-exp dll.exp
C:\Perl64\site\bin\g++.exe -o blib\arch\auto\BerkeleyDB\BerkeleyDB.dll -Wl,--base-file -Wl,dll.base -mdll -L"C:\Perl64\lib\CORE" BerkeleyDB.o   C:\Perl64\lib\CORE\perl516.lib C:\App\BerkeleyDB4.7.25\lib\libdb47.lib dll.exp
BerkeleyDB.o:BerkeleyDB.c:(.text+0x536): undefined reference to `db_strerror'
...
BerkeleyDB.o:BerkeleyDB.c:(.text+0xd5d): undefined reference to `db_strerror'
BerkeleyDB.o:BerkeleyDB.c:(.text+0xf6d): more undefined references to `db_strerror' follow
BerkeleyDB.o:BerkeleyDB.c:(.text+0x1a73): undefined reference to `db_version'
BerkeleyDB.o:BerkeleyDB.c:(.text+0x1eb8): undefined reference to `db_strerror'
...
BerkeleyDB.o:BerkeleyDB.c:(.text+0x3793): undefined reference to `db_strerror'
BerkeleyDB.o:BerkeleyDB.c:(.text+0x39a6): more undefined references to `db_strerror' follow
BerkeleyDB.o:BerkeleyDB.c:(.text+0xa877): undefined reference to `db_sequence_create'
BerkeleyDB.o:BerkeleyDB.c:(.text+0xabb9): undefined reference to `db_strerror'
...
BerkeleyDB.o:BerkeleyDB.c:(.text+0xe10a): undefined reference to `db_strerror'
BerkeleyDB.o:BerkeleyDB.c:(.text+0xeb30): more undefined references to `db_strerror' follow
BerkeleyDB.o:BerkeleyDB.c:(.text+0x18224): undefined reference to `db_create'
BerkeleyDB.o:BerkeleyDB.c:(.text+0x1825e): undefined reference to `db_strerror'
BerkeleyDB.o:BerkeleyDB.c:(.text+0x184f4): undefined reference to `db_create'
BerkeleyDB.o:BerkeleyDB.c:(.text+0x1852e): undefined reference to `db_strerror'
BerkeleyDB.o:BerkeleyDB.c:(.text+0x189b9): undefined reference to `db_env_create'
BerkeleyDB.o:BerkeleyDB.c:(.text+0x18ccc): undefined reference to `db_create'
BerkeleyDB.o:BerkeleyDB.c:(.text+0x18dd8): undefined reference to `db_strerror'
BerkeleyDB.o:BerkeleyDB.c:(.text+0x19799): undefined reference to `db_strerror'
BerkeleyDB.o:BerkeleyDB.c:(.text+0x20e53): undefined reference to `db_env_create'
BerkeleyDB.o:BerkeleyDB.c:(.text+0x20fcb): undefined reference to `db_strerror'
BerkeleyDB.o:BerkeleyDB.c:(.text+0x219ad): undefined reference to `db_create'
BerkeleyDB.o:BerkeleyDB.c:(.text+0x26a9a): undefined reference to `db_version'


c:/perl64/site/lib/auto/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.5.4/../../../../x86_64-w64-mingw32/bin/ld.exe: BerkeleyDB.o: bad reloc address 0x20 in section `.data'


c:/perl64/site/lib/auto/mingw/bin/../lib/gcc/x86_64-w64-mingw32/4.5.4/../../../../x86_64-w64-mingw32/bin/ld.exe: final link failed: Invalid operation


collect2: ld returned 1 exit status

dmake.exe:  Error code 129, while making 'blib\arch\auto\BerkeleyDB\BerkeleyDB.dll'

I would very much appreciate your assistance.

Comments like 'change to Strawberry, change to Linux, ...' are welcome, but I hope we can fix this problem in the current environment.

Georgeanngeorgeanna answered 4/11, 2014 at 8:7 Comment(4)
I noticed your output showed "unchanged" after changing DBNAME. Often configure scripts cache settings they shouldn't. Can you please start project over (sometimes make clean doesn't do a good job) -- meaning delete entire project root and re-start with freshly extracted source -- and run configure/compile (make) all with correct parameters on first try?Stevenstevena
According to the pm status code.activestate.com/ppm/BerkeleyDB, this perl module has never worked for Windows. Getting this to work sounds like it will take diving into source code and making appropriate modifications.Stevenstevena
did you ever figure this out?Shipman
@james28909: No. I try to avoid perl on windows completely because also mod_perl is a pain on windows.Georgeanngeorgeanna
M
-3

I haven't used BerkeleyDB module, but here is my attempt to be of help to you.

First of all, BerkeleyDB is a DB written in C, by oracle, with current latest version being 6.x (as you mentioned). But I did not see, any mention about x64 version of the msi installer for the same. All it says is a .msi installer, so I assume, it is most likely x86(32 bit) and not x64. And might be causing problems.

BerkeleyDB.pm on the otherhand claims to support the version 6 as well, indeed the documentation is not clear yet. But I feel it is likely that it does support it. Plus, it seems to be a well tested and used module.

Further it seems you are using ActiveStatePerl, which has nothing wrong about it, but it might be worth a try, to install StrawberryPerl instead, THAT IS given you have not become already familiar with activestateperl plus unfamiliar with the later.

Mortmain answered 9/11, 2014 at 14:50 Comment(5)
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post.Barcus
If you read the question more clearly, my answer is perfectly fine, it is neither criticism or request for clarification.Mortmain
However true that may be, it does not provide a definitive answer.Barcus
An answer is a answer to the question, and whether it is definitive or not(in your eyes), is of less concern. Neither does it warrants you to be picky about it.Mortmain
I agree with @Rory Mccrossan. This is a list of things to try - an extended comment - not an answer.Ninepins

© 2022 - 2024 — McMap. All rights reserved.