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.