Blame README

Packit bc69c3
                                  DB_File
Packit bc69c3
Packit bc69c3
                               Version 1.842
Packit bc69c3
Packit bc69c3
                                14 July 2018
Packit bc69c3
Packit bc69c3
     Copyright (c) 1995-2018 Paul Marquess. All rights reserved. This
Packit bc69c3
      program is free software; you can redistribute it and/or modify
Packit bc69c3
                  it under the same terms as Perl itself.
Packit bc69c3
Packit bc69c3
Packit bc69c3
IMPORTANT NOTICE
Packit bc69c3
================
Packit bc69c3
Packit bc69c3
If are using the locking technique described in older versions of
Packit bc69c3
DB_File, please read the section called "Locking: The Trouble with fd"
Packit bc69c3
in DB_File.pm immediately. The locking method has been found to be
Packit bc69c3
unsafe. You risk corrupting your data if you continue to use it.
Packit bc69c3
Packit bc69c3
DESCRIPTION
Packit bc69c3
-----------
Packit bc69c3
Packit bc69c3
DB_File is a module which allows Perl programs to make use of the
Packit bc69c3
facilities provided by Berkeley DB version 1. (DB_File can be built
Packit bc69c3
version 2, or greater, of Berkeley DB, but it will only support the 1.x
Packit bc69c3
features).
Packit bc69c3
Packit bc69c3
If you want to make use of the new features available in Berkeley DB
Packit bc69c3
2.x, or greater, use the Perl module BerkeleyDB instead.
Packit bc69c3
Packit bc69c3
Berkeley DB is a C library which provides a consistent interface to a
Packit bc69c3
number of database formats. DB_File provides an interface to all three
Packit bc69c3
of the database types (hash, btree and recno) currently supported by
Packit bc69c3
Berkeley DB.
Packit bc69c3
Packit bc69c3
For further details see the documentation included at the end of the
Packit bc69c3
file DB_File.pm.
Packit bc69c3
Packit bc69c3
PREREQUISITES
Packit bc69c3
-------------
Packit bc69c3
Packit bc69c3
Before you can build DB_File you must have the following installed on
Packit bc69c3
your system:
Packit bc69c3
Packit bc69c3
    * Perl 5.8.3 or greater.
Packit bc69c3
Packit bc69c3
    * Berkeley DB.
Packit bc69c3
Packit bc69c3
      The official web site for Berkeley DB is 
Packit bc69c3
Packit bc69c3
        http://www.oracle.com/technology/products/berkeley-db/db/index.html
Packit bc69c3
Packit bc69c3
      The latest version of Berkeley DB is always available there. It
Packit bc69c3
      is recommended that you use the most recent version available.
Packit bc69c3
Packit bc69c3
      The one exception to this advice is where you want to use DB_File
Packit bc69c3
      to access database files created by a third-party application, like
Packit bc69c3
      Sendmail or Netscape. In these cases you must build DB_File with a
Packit bc69c3
      compatible version of Berkeley DB.
Packit bc69c3
Packit bc69c3
      If you want to use Berkeley DB 2.x, you must have version 2.3.4
Packit bc69c3
      or greater.  If you want to use Berkeley DB 3.x or 4.x, any version
Packit bc69c3
      will do. For Berkeley DB 1.x, use either version 1.85 or 1.86.
Packit bc69c3
Packit bc69c3
Packit bc69c3
BUILDING THE MODULE
Packit bc69c3
-------------------
Packit bc69c3
Packit bc69c3
Assuming you have met all the prerequisites, building the module should
Packit bc69c3
be relatively straightforward.
Packit bc69c3
Packit bc69c3
Step 1 : If you are running either Solaris 2.5 or HP-UX 10 and want
Packit bc69c3
         to use Berkeley DB version 2, 3 or 4, read either the Solaris Notes
Packit bc69c3
         or HP-UX Notes sections below.  If you are running Linux please
Packit bc69c3
         read the Linux Notes section before proceeding.
Packit bc69c3
Packit bc69c3
Step 2 : Edit the file config.in to suit you local installation.
Packit bc69c3
         Instructions are given in the file.
Packit bc69c3
Packit bc69c3
Step 3 : Build and test the module using this sequence of commands:
Packit bc69c3
Packit bc69c3
             perl Makefile.PL
Packit bc69c3
             make
Packit bc69c3
             make test
Packit bc69c3
Packit bc69c3
Packit bc69c3
  NOTE:
Packit bc69c3
      If you have a very old version of Berkeley DB (i.e. pre 1.85),
Packit bc69c3
      three of the tests in the recno test harness may fail (tests 51,
Packit bc69c3
      53 and 55). You can safely ignore the errors if you're never
Packit bc69c3
      going to use the broken functionality (recno databases with a
Packit bc69c3
      modified bval).  Otherwise you'll have to upgrade your DB
Packit bc69c3
      library.
Packit bc69c3
Packit bc69c3
Packit bc69c3
INSTALLATION
Packit bc69c3
------------
Packit bc69c3
Packit bc69c3
    make install
Packit bc69c3
Packit bc69c3
UPDATES
Packit bc69c3
=======
Packit bc69c3
Packit bc69c3
The most recent version of DB_File is always available at 
Packit bc69c3
Packit bc69c3
    http://www.cpan.org/modules/by-module/DB_File/
Packit bc69c3
Packit bc69c3
TROUBLESHOOTING
Packit bc69c3
===============
Packit bc69c3
Packit bc69c3
Here are some of the common problems people encounter when building
Packit bc69c3
DB_File.
Packit bc69c3
Packit bc69c3
Missing db.h or libdb.a
Packit bc69c3
-----------------------
Packit bc69c3
Packit bc69c3
If you get an error like this:
Packit bc69c3
Packit bc69c3
  cc -c -I/usr/local/include -Dbool=char -DHAS_BOOL
Packit bc69c3
  -O2    -DVERSION=\"1.64\" -DXS_VERSION=\"1.64\" -fpic
Packit bc69c3
  -I/usr/local/lib/perl5/i586-linux/5.00404/CORE -DmDB_Prefix_t=size_t
Packit bc69c3
  -DmDB_Hash_t=u_int32_t DB_File.c
Packit bc69c3
  DB_File.xs:101: db.h: No such file or directory
Packit bc69c3
Packit bc69c3
or this:
Packit bc69c3
Packit bc69c3
  LD_RUN_PATH="/lib" cc -o blib/arch/auto/DB_File/DB_File.so  -shared
Packit bc69c3
  -L/usr/local/lib DB_File.o    -L/usr/local/lib -ldb
Packit bc69c3
  ld: cannot open -ldb: No such file or directory
Packit bc69c3
Packit bc69c3
This symptom can imply:
Packit bc69c3
Packit bc69c3
 1. You don't have Berkeley DB installed on your system at all.
Packit bc69c3
    Solution: get & install Berkeley DB.
Packit bc69c3
Packit bc69c3
 2. You do have Berkeley DB installed, but it isn't in a standard place.
Packit bc69c3
    Solution: Edit config.in and set the LIB and INCLUDE variables to point
Packit bc69c3
              to the directories where libdb.a and db.h are installed.
Packit bc69c3
Packit bc69c3
Packit bc69c3
Packit bc69c3
Packit bc69c3
Undefined symbol db_version
Packit bc69c3
---------------------------
Packit bc69c3
Packit bc69c3
DB_File seems to have built correctly, but you get an error like this
Packit bc69c3
when you run the test harness:
Packit bc69c3
Packit bc69c3
  $ make test
Packit bc69c3
  PERL_DL_NONLAZY=1 /usr/bin/perl5.00404 -I./blib/arch -I./blib/lib
Packit bc69c3
  -I/usr/local/lib/perl5/i586-linux/5.00404 -I/usr/local/lib/perl5 -e 'use
Packit bc69c3
  Test::Harness qw(&runtests $verbose); $verbose=0; runtests @ARGV;' t/*.t
Packit bc69c3
  t/db-btree..........Can't load './blib/arch/auto/DB_File/DB_File.so' for
Packit bc69c3
  module DB_File: ./blib/arch/auto/DB_File/DB_File.so: undefined symbol:
Packit bc69c3
  db_version at /usr/local/lib/perl5/i586-linux/5.00404/DynaLoader.pm
Packit bc69c3
  line 166.
Packit bc69c3
Packit bc69c3
  at t/db-btree.t line 21
Packit bc69c3
  BEGIN failed--compilation aborted at t/db-btree.t line 21.
Packit bc69c3
  dubious Test returned status 2 (wstat 512, 0x200)
Packit bc69c3
Packit bc69c3
This error usually happens when you have two version of Berkeley DB
Packit bc69c3
installed on your system -- specifically, if you have both version 1 and
Packit bc69c3
a newer version (i.e. version 2 or better) of Berkeley DB installed. If
Packit bc69c3
DB_File is built using the db.h for the newer Berkeley DB and the version
Packit bc69c3
1 Berkeley DB library you will trigger this error. Unfortunately the two
Packit bc69c3
versions aren't compatible with each other. The undefined symbol error is
Packit bc69c3
caused because Berkeley DB version 1 doesn't have the symbol db_version.
Packit bc69c3
Packit bc69c3
Solution: Setting the LIB & INCLUDE variables in config.in to point to the
Packit bc69c3
          correct directories can sometimes be enough to fix this
Packit bc69c3
          problem. If that doesn't work the easiest way to fix the
Packit bc69c3
          problem is to either delete or temporarily rename the copies
Packit bc69c3
          of db.h and libdb.a that you don't want DB_File to use.
Packit bc69c3
Packit bc69c3
Packit bc69c3
Undefined symbol dbopen
Packit bc69c3
-----------------------
Packit bc69c3
Packit bc69c3
DB_File seems to have built correctly, but you get an error like this
Packit bc69c3
when you run the test harness:
Packit bc69c3
Packit bc69c3
  ...
Packit bc69c3
  t/db-btree..........Can't load 'blib/arch/auto/DB_File/DB_File.so' for
Packit bc69c3
  module DB_File: blib/arch/auto/DB_File/DB_File.so: undefined symbol:
Packit bc69c3
  dbopen at /usr/local/lib/perl5/5.6.1/i586-linux/DynaLoader.pm line 206.
Packit bc69c3
   at t/db-btree.t line 23
Packit bc69c3
  Compilation failed in require at t/db-btree.t line 23.
Packit bc69c3
  ...
Packit bc69c3
Packit bc69c3
This error usually happens when you have both version 1 and a more recent
Packit bc69c3
version of Berkeley DB installed on your system and DB_File attempts
Packit bc69c3
to build using the db.h for Berkeley DB version 1 and the newer version
Packit bc69c3
library. Unfortunately the two versions aren't compatible with each
Packit bc69c3
other. The undefined symbol error is actually caused because versions
Packit bc69c3
of Berkeley DB newer than version 1 doesn't have the symbol dbopen.
Packit bc69c3
Packit bc69c3
Solution: Setting the LIB & INCLUDE variables in config.in to point to the
Packit bc69c3
          correct directories can sometimes be enough to fix this
Packit bc69c3
          problem. If that doesn't work the easiest way to fix the
Packit bc69c3
          problem is to either delete or temporarily rename the copies
Packit bc69c3
          of db.h and libdb.a that you don't want DB_File to use.
Packit bc69c3
Packit bc69c3
Packit bc69c3
Incompatible versions of db.h and libdb
Packit bc69c3
---------------------------------------
Packit bc69c3
Packit bc69c3
DB_File seems to have built correctly, but you get an error like this
Packit bc69c3
when you run the test harness:
Packit bc69c3
Packit bc69c3
  $ make test
Packit bc69c3
  PERL_DL_NONLAZY=1 /home/paul/perl/install/bin/perl5.00560 -Iblib/arch
Packit bc69c3
  -Iblib/lib -I/home/paul/perl/install/5.005_60/lib/5.00560/i586-linux
Packit bc69c3
  -I/home/paul/perl/install/5.005_60/lib/5.00560 -e 'use Test::Harness
Packit bc69c3
  qw(&runtests $verbose); $verbose=0; runtests @ARGV;' t/*.t
Packit bc69c3
  t/db-btree..........
Packit bc69c3
  DB_File was build with libdb version 2.3.7
Packit bc69c3
  but you are attempting to run it with libdb version 2.7.5
Packit bc69c3
  BEGIN failed--compilation aborted at t/db-btree.t line 21.
Packit bc69c3
  ...
Packit bc69c3
Packit bc69c3
Another variation on the theme of having two versions of Berkeley DB on
Packit bc69c3
your system.
Packit bc69c3
Packit bc69c3
Solution: Setting the LIB & INCLUDE variables in config.in to point to the
Packit bc69c3
          correct directories can sometimes be enough to fix this
Packit bc69c3
          problem. If that doesn't work the easiest way to fix the
Packit bc69c3
          problem is to either delete or temporarily rename the copies
Packit bc69c3
          of db.h and libdb.a that you don't want BerkeleyDB to use.
Packit bc69c3
          If you are running Linux, please read the Linux Notes section
Packit bc69c3
          below.
Packit bc69c3
Packit bc69c3
Keep getting "At least one secondary cursor must be specified to DB->join"
Packit bc69c3
--------------------------------------------------------------------------
Packit bc69c3
Packit bc69c3
When you either run the DB_File test harness, or attempt to run a script
Packit bc69c3
that uses DB_File you get the error message below.
Packit bc69c3
Packit bc69c3
    BDB0588 At least one secondary cursor must be specified to DB->join.
Packit bc69c3
Packit bc69c3
To date thus issue has only been reported on Windows. If you encounter this
Packit bc69c3
issue on another platform, please report the issue. See the FEEDBACK
Packit bc69c3
section for details.
Packit bc69c3
Packit bc69c3
This issue boils down to the size of the C type time_t. 
Packit bc69c3
Packit bc69c3
The typical reason for getting this error is when running a 32-bit Perl
Packit bc69c3
(which will use a 32-bit time_t) along with a 32-bit Berkeley DB library.
Packit bc69c3
The key point is how Berkeley DB has been built. If it has been built with
Packit bc69c3
a newish version of Visual C++, time_t will default to 64-bit, even when
Packit bc69c3
the rest of the library has been built 32-bit. This means that Perl thinks
Packit bc69c3
time_t is 32-bit, but Berkeley DB thinks it is 64-bit. 
Packit bc69c3
Packit bc69c3
More details of how the size of time_t in Windows is shown below (taken
Packit bc69c3
from http://msdn.microsoft.com/en-us/library/w4ddyt9h.aspx)
Packit bc69c3
Packit bc69c3
    In versions of Visual C++ and Microsoft C/C++ before Visual C++ 2005,
Packit bc69c3
    time_t was a long int (32 bits) and hence could not be used for dates
Packit bc69c3
    past 3:14:07 January 19, 2038, UTC. time_t is now equivalent to
Packit bc69c3
    __time64_t by default, but defining _USE_32BIT_TIME_T changes time_t
Packit bc69c3
    to __time32_t and forces many time functions to call versions that take
Packit bc69c3
    the 32-bit time_t.
Packit bc69c3
Packit bc69c3
Packit bc69c3
When DB_File is built, it uses a Berkeley DB header file, called db.h. This
Packit bc69c3
file contains the definition of a number of key data structures used by
Packit bc69c3
Berkeley DB. Unfortunately one of those data structures includes a time_t.
Packit bc69c3
This is the root case for this issue. When you build DB_File, it assumes
Packit bc69c3
time_t is 32-bit, but the Berkeley DB library is expecting it to be 64-bit.
Packit bc69c3
Packit bc69c3
Solution: 
Packit bc69c3
Packit bc69c3
There are a few options available.
Packit bc69c3
Packit bc69c3
1. Use a 64-bit Perl along with a 64-bit Berkleley DB.
Packit bc69c3
Packit bc69c3
2. Use a 32-bit Perl along with a 32-bit Berkeley DB where _USE_32BIT_TIME_T
Packit bc69c3
   has been defined.
Packit bc69c3
Packit bc69c3
3. If you do need to interoperate with a Berkeley DB library that uses a
Packit bc69c3
   time_t that is different from Perl you need to edit the file DB_File.xs
Packit bc69c3
   and find these lines
Packit bc69c3
Packit bc69c3
        /* #define time_t __time64_t */
Packit bc69c3
        /* #define time_t __time32_t */
Packit bc69c3
Packit bc69c3
    If your Berkeley DB library uses a 64-bit time_t, uncomment the first line.
Packit bc69c3
    If your Berkeley DB library uses a 32-bit time_t, uncomment the second line.
Packit bc69c3
Packit bc69c3
Packit bc69c3
Packit bc69c3
MacOS Notes
Packit bc69c3
-------------
Packit bc69c3
Packit bc69c3
You are running MacOS 10.13 (or possibly later), and the test DB_File test harness file
Packit bc69c3
db-hash.t fails like this
Packit bc69c3
Packit bc69c3
    t/db-btree.t .. ok       
Packit bc69c3
    t/db-hash.t ... Use of uninitialized value $value in string eq at t/db-hash.t line 224.
Packit bc69c3
    Use of uninitialized value $values[0] in string eq at t/db-hash.t line 224.
Packit bc69c3
    Use of uninitialized value $value in lc at t/db-hash.t line 224.
Packit bc69c3
    Use of uninitialized value $h{""} in string eq at t/db-hash.t line 243.
Packit bc69c3
    Use of uninitialized value in numeric eq (==) at t/db-hash.t line 252.
Packit bc69c3
    Use of uninitialized value in numeric eq (==) at t/db-hash.t line 252.
Packit bc69c3
    Use of uninitialized value in numeric eq (==) at t/db-hash.t line 252.
Packit bc69c3
    Use of uninitialized value in numeric eq (==) at t/db-hash.t line 252.
Packit bc69c3
    Use of uninitialized value in numeric eq (==) at t/db-hash.t line 252.
Packit bc69c3
    Use of uninitialized value in numeric eq (==) at t/db-hash.t line 252.
Packit bc69c3
    Use of uninitialized value in numeric eq (==) at t/db-hash.t line 252.
Packit bc69c3
    Use of uninitialized value in numeric eq (==) at t/db-hash.t line 252.
Packit bc69c3
    Use of uninitialized value $foo[18] in join or string at t/db-hash.t line 261.
Packit bc69c3
    Use of uninitialized value $foo[36] in join or string at t/db-hash.t line 261.
Packit bc69c3
    Use of uninitialized value $foo[48] in join or string at t/db-hash.t line 261.
Packit bc69c3
    Use of uninitialized value $foo[58] in join or string at t/db-hash.t line 261.
Packit bc69c3
    Use of uninitialized value $foo[59] in join or string at t/db-hash.t line 261.
Packit bc69c3
    Use of uninitialized value $foo[60] in join or string at t/db-hash.t line 261.
Packit bc69c3
    Use of uninitialized value $foo[62] in join or string at t/db-hash.t line 261.
Packit bc69c3
    Use of uninitialized value $foo[63] in join or string at t/db-hash.t line 261.
Packit bc69c3
    Use of uninitialized value $foo[92] in join or string at t/db-hash.t line 261.
Packit bc69c3
    Use of uninitialized value $foo[114] in join or string at t/db-hash.t line 261.
Packit bc69c3
    Use of uninitialized value $foo[140] in join or string at t/db-hash.t line 261.
Packit bc69c3
    Use of uninitialized value $foo[187] in join or string at t/db-hash.t line 261.
Packit bc69c3
    Use of uninitialized value $foo[188] in join or string at t/db-hash.t line 261.
Packit bc69c3
    Use of uninitialized value $foo[189] in join or string at t/db-hash.t line 261.
Packit bc69c3
    t/db-hash.t ... 1/166 Use of uninitialized value $h{"Fred"} in string eq at t/db-hash.t line 572.
Packit bc69c3
    Use of uninitialized value $v in concatenation (.) or string at t/db-hash.t line 748.
Packit bc69c3
    t/db-hash.t ... Dubious, test returned 25 (wstat 6400, 0x1900)
Packit bc69c3
    Failed 76/166 subtests 
Packit bc69c3
    t/db-recno.t .. ok       
Packit bc69c3
    t/pod.t ....... ok   
Packit bc69c3
Packit bc69c3
Packit bc69c3
It appears that MacOS 10.13 has a copy of BerkeleyDB version 1 included in
Packit bc69c3
/usr/lib/system/libsystem_c.dylib. It is not clear why this isn't working
Packit bc69c3
with this module. The following ticket has been reported to Apple
Packit bc69c3
https://discussions.apple.com/thread/8125401
Packit bc69c3
Packit bc69c3
Solution
Packit bc69c3
Packit bc69c3
It has been reported that this issue can be resolved by installing a
Packit bc69c3
separate version of the Berkeley DB library and configuring DB_File to use
Packit bc69c3
it.
Packit bc69c3
Packit bc69c3
One option is to use a prebuild version of Berkeley DB. One is available at
Packit bc69c3
MacPorts (https://www.macports.org/). Once you have MacPorts installed, run
Packit bc69c3
this
Packit bc69c3
Packit bc69c3
    sudo port install db48
Packit bc69c3
Packit bc69c3
To get DB_File to use this library edit config.in and change the values for
Packit bc69c3
the LIB and include variables as follows
Packit bc69c3
Packit bc69c3
    LIB        = /opt/local/lib/db48
Packit bc69c3
    INCLUDE    = /opt/local/include/db48
Packit bc69c3
Packit bc69c3
Alternatively, set the two envornment variables DB_FILE_LIB and DB_FILE_INCLUDE
Packit bc69c3
as follows
Packit bc69c3
Packit bc69c3
    export DB_FILE_LIB=/opt/local/lib/db48
Packit bc69c3
    export DB_FILE_INCLUDE=/opt/local/include/db48 
Packit bc69c3
Packit bc69c3
Now rebuild DB_File from scratch.
Packit bc69c3
Packit bc69c3
Packit bc69c3
Packit bc69c3
Solaris build fails with "language optional software package not installed"
Packit bc69c3
---------------------------------------------------------------------------
Packit bc69c3
Packit bc69c3
If you are trying to build this module under Solaris and you get an
Packit bc69c3
error message like this
Packit bc69c3
Packit bc69c3
    /usr/ucb/cc: language optional software package not installed
Packit bc69c3
Packit bc69c3
it means that Perl cannot find the C compiler on your system. The cryptic
Packit bc69c3
message is just Sun's way of telling you that you haven't bought their
Packit bc69c3
C compiler.
Packit bc69c3
Packit bc69c3
When you build a Perl module that needs a C compiler, the Perl build
Packit bc69c3
system tries to use the same C compiler that was used to build perl
Packit bc69c3
itself. In this case your Perl binary was built with a C compiler that
Packit bc69c3
lived in /usr/ucb.
Packit bc69c3
Packit bc69c3
To continue with building this module, you need to get a C compiler,
Packit bc69c3
or tell Perl where your C compiler is, if you already have one.
Packit bc69c3
Packit bc69c3
Assuming you have now got a C compiler, what you do next will be dependant
Packit bc69c3
on what C compiler you have installed. If you have just installed Sun's
Packit bc69c3
C compiler, you shouldn't have to do anything. Just try rebuilding
Packit bc69c3
this module.
Packit bc69c3
Packit bc69c3
If you have installed another C compiler, say gcc, you have to tell perl
Packit bc69c3
how to use it instead of /usr/ucb/cc.
Packit bc69c3
Packit bc69c3
This set of options seems to work if you want to use gcc. Your mileage
Packit bc69c3
may vary.
Packit bc69c3
Packit bc69c3
    perl Makefile.PL CC=gcc CCCDLFLAGS=-fPIC OPTIMIZE=" "
Packit bc69c3
    make test
Packit bc69c3
Packit bc69c3
If that doesn't work for you, it's time to make changes to the Makefile
Packit bc69c3
by hand. Good luck!
Packit bc69c3
Packit bc69c3
Packit bc69c3
Packit bc69c3
Solaris build fails with "gcc: unrecognized option `-KPIC'"
Packit bc69c3
-----------------------------------------------------------
Packit bc69c3
Packit bc69c3
You are running Solaris and you get an error like this when you try to
Packit bc69c3
build this Perl module
Packit bc69c3
Packit bc69c3
    gcc: unrecognized option `-KPIC'
Packit bc69c3
Packit bc69c3
This symptom usually means that you are using a Perl binary that has been
Packit bc69c3
built with the Sun C compiler, but you are using gcc to build this module.
Packit bc69c3
Packit bc69c3
When Perl builds modules that need a C compiler, it will attempt to use
Packit bc69c3
the same C compiler and command line options that was used to build perl
Packit bc69c3
itself. In this case "-KPIC" is a valid option for the Sun C compiler,
Packit bc69c3
but not for gcc. The equivalent option for gcc is "-fPIC".
Packit bc69c3
Packit bc69c3
The solution is either:
Packit bc69c3
Packit bc69c3
    1. Build both Perl and this module with the same C compiler, either
Packit bc69c3
       by using the Sun C compiler for both or gcc for both.
Packit bc69c3
Packit bc69c3
    2. Try generating the Makefile for this module like this perl
Packit bc69c3
Packit bc69c3
           perl Makefile.PL CC=gcc CCCDLFLAGS=-fPIC OPTIMIZE=" " LD=gcc
Packit bc69c3
           make test
Packit bc69c3
Packit bc69c3
       This second option seems to work when mixing a Perl binary built
Packit bc69c3
       with the Sun C compiler and this module built with gcc. Your
Packit bc69c3
       mileage may vary.
Packit bc69c3
Packit bc69c3
Packit bc69c3
Packit bc69c3
Packit bc69c3
Linux Notes
Packit bc69c3
-----------
Packit bc69c3
Packit bc69c3
Some older versions of Linux (e.g. RedHat 6, SuSe 6) ship with a C library
Packit bc69c3
that has version 2.x of Berkeley DB linked into it. This makes it
Packit bc69c3
difficult to build this module with anything other than the version of
Packit bc69c3
Berkeley DB that shipped with your Linux release. If you do try to use
Packit bc69c3
a different version of Berkeley DB you will most likely get the error
Packit bc69c3
described in the "Incompatible versions of db.h and libdb" section of
Packit bc69c3
this file.
Packit bc69c3
Packit bc69c3
To make matters worse, prior to Perl 5.6.1, the perl binary itself
Packit bc69c3
*always* included the Berkeley DB library.
Packit bc69c3
Packit bc69c3
If you want to use a newer version of Berkeley DB with this module, the
Packit bc69c3
easiest solution is to use Perl 5.6.1 (or better) and Berkeley DB 3.x
Packit bc69c3
(or better).
Packit bc69c3
Packit bc69c3
There are two approaches you can use to get older versions of Perl to
Packit bc69c3
work with specific versions of Berkeley DB. Both have their advantages
Packit bc69c3
and disadvantages.
Packit bc69c3
Packit bc69c3
The first approach will only work when you want to build a version of
Packit bc69c3
Perl older than 5.6.1 along with Berkeley DB 3.x. If you want to use
Packit bc69c3
Berkeley DB 2.x, you must use the next approach. This approach involves
Packit bc69c3
rebuilding your existing version of Perl after applying an unofficial
Packit bc69c3
patch. The "patches" directory in the this module's source distribution
Packit bc69c3
contains a number of patch files. There is one patch file for every
Packit bc69c3
stable version of Perl since 5.004. Apply the appropriate patch to your
Packit bc69c3
Perl source tree before re-building and installing Perl from scratch.
Packit bc69c3
For example, assuming you are in the top-level source directory for
Packit bc69c3
Perl 5.6.0, the command below will apply the necessary patch. Remember
Packit bc69c3
to replace the path shown below with one that points to this module's
Packit bc69c3
patches directory.
Packit bc69c3
Packit bc69c3
    patch -p1 -N 
Packit bc69c3
Packit bc69c3
Now rebuild & install perl. You should now have a perl binary that can
Packit bc69c3
be used to build this module. Follow the instructions in "BUILDING THE
Packit bc69c3
MODULE", remembering to set the INCLUDE and LIB variables in config.in.
Packit bc69c3
Packit bc69c3
Packit bc69c3
The second approach will work with both Berkeley DB 2.x and 3.x.
Packit bc69c3
Start by building Berkeley DB as a shared library. This is from
Packit bc69c3
the Berkeley DB build instructions:
Packit bc69c3
Packit bc69c3
    Building Shared Libraries for the GNU GCC compiler
Packit bc69c3
Packit bc69c3
    If you're using gcc and there's no better shared library example for
Packit bc69c3
    your architecture, the following shared library build procedure will
Packit bc69c3
    probably work.
Packit bc69c3
Packit bc69c3
    Add the -fpic option to the CFLAGS value in the Makefile.
Packit bc69c3
Packit bc69c3
    Rebuild all of your .o files. This will create a Berkeley DB library
Packit bc69c3
    that contains .o files with PIC code. To build the shared library,
Packit bc69c3
    then take the following steps in the library build directory:
Packit bc69c3
Packit bc69c3
    % mkdir tmp
Packit bc69c3
    % cd tmp
Packit bc69c3
    % ar xv ../libdb.a
Packit bc69c3
    % gcc -shared -o libdb.so *.o
Packit bc69c3
    % mv libdb.so ..
Packit bc69c3
    % cd ..
Packit bc69c3
    % rm -rf tmp
Packit bc69c3
Packit bc69c3
    Note, you may have to change the gcc line depending on the
Packit bc69c3
    requirements of your system.
Packit bc69c3
Packit bc69c3
    The file libdb.so is your shared library
Packit bc69c3
Packit bc69c3
Once you have built libdb.so, you will need to store it somewhere safe.
Packit bc69c3
Packit bc69c3
    cp libdb.so /usr/local/BerkeleyDB/lib
Packit bc69c3
Packit bc69c3
If you now set the LD_PRELOAD environment variable to point to this
Packit bc69c3
shared library, Perl will use it instead of the version of Berkeley DB
Packit bc69c3
that shipped with your Linux distribution.
Packit bc69c3
Packit bc69c3
    export LD_PRELOAD=/usr/local/BerkeleyDB/lib/libdb.so
Packit bc69c3
Packit bc69c3
Finally follow the instructions in "BUILDING THE MODULE" to build,
Packit bc69c3
test and install this module. Don't forget to set the INCLUDE and LIB
Packit bc69c3
variables in config.in.
Packit bc69c3
Packit bc69c3
Remember, you will need to have the LD_PRELOAD variable set anytime you
Packit bc69c3
want to use Perl with Berkeley DB. Also note that if you have LD_PRELOAD
Packit bc69c3
permanently set it will affect ALL commands you execute. This may be a
Packit bc69c3
problem if you run any commands that access a database created by the
Packit bc69c3
version of Berkeley DB that shipped with your Linux distribution.
Packit bc69c3
Packit bc69c3
Packit bc69c3
Solaris Notes
Packit bc69c3
-------------
Packit bc69c3
Packit bc69c3
If you are running Solaris 2.5, and you get this error when you run the
Packit bc69c3
DB_File test harness:
Packit bc69c3
Packit bc69c3
    libc internal error: _rmutex_unlock: rmutex not held.
Packit bc69c3
Packit bc69c3
you probably need to install a Sun patch. It has been reported that
Packit bc69c3
Sun patch 103187-25 (or later revisions) fixes this problem.
Packit bc69c3
Packit bc69c3
To find out if you have the patch installed, the command "showrev -p"
Packit bc69c3
will display the patches that are currently installed on your system.
Packit bc69c3
Packit bc69c3
Packit bc69c3
HP-UX 10 Notes
Packit bc69c3
--------------
Packit bc69c3
Packit bc69c3
Some people running HP-UX 10 have reported getting an error like this
Packit bc69c3
when building DB_File with the native HP-UX compiler.
Packit bc69c3
Packit bc69c3
    ld: (Warning) At least one PA 2.0 object file (DB_File.o) was detected.
Packit bc69c3
    The linked output may not run on a PA 1.x system.
Packit bc69c3
    ld: Invalid loader fixup for symbol "$000000A5".
Packit bc69c3
Packit bc69c3
If this is the case for you, Berkeley DB needs to be recompiled with
Packit bc69c3
the +z or +Z option and the resulting library placed in a .sl file. The
Packit bc69c3
following steps should do the trick:
Packit bc69c3
Packit bc69c3
  1: Configure the Berkeley DB distribution with the +z or +Z C compiler
Packit bc69c3
     flag:
Packit bc69c3
Packit bc69c3
        env "CFLAGS=+z" ../dist/configure ...
Packit bc69c3
Packit bc69c3
  2: Edit the Berkeley DB Makefile and change:
Packit bc69c3
Packit bc69c3
        "libdb= libdb.a" to "libdb= libdb.sl".
Packit bc69c3
Packit bc69c3
Packit bc69c3
  3: Build and install the Berkeley DB distribution as usual.
Packit bc69c3
Packit bc69c3
HP-UX 11 Notes
Packit bc69c3
--------------
Packit bc69c3
Packit bc69c3
Some people running the combination of HP-UX 11 and Berkeley DB 2.7.7 have
Packit bc69c3
reported getting this error when the run the test harness for DB_File
Packit bc69c3
Packit bc69c3
    ...
Packit bc69c3
    lib/db-btree.........Can't call method "DELETE" on an undefined value at lib/db-btree.t line 216.
Packit bc69c3
    FAILED at test 26
Packit bc69c3
    lib/db-hash..........Can't call method "DELETE" on an undefined value at lib/db-hash.t line 183.
Packit bc69c3
    FAILED at test 22
Packit bc69c3
    ...
Packit bc69c3
Packit bc69c3
The fix for this is to rebuild and install Berkeley DB with the bigfile
Packit bc69c3
option disabled.
Packit bc69c3
Packit bc69c3
Packit bc69c3
AIX NOTES
Packit bc69c3
---------
Packit bc69c3
Packit bc69c3
I've had reports of a build failure like this on AIX 5.2 using the
Packit bc69c3
xlC compiler.
Packit bc69c3
Packit bc69c3
        rm -f blib/arch/auto/DB_File/DB_File.so
Packit bc69c3
        LD_RUN_PATH="" ld  -bhalt:4 -bM:SRE -bI:/usr/local/5.8.1/lib/perl5/5.8.1/aix/CORE/perl.exp -bE:DB_File.exp -bnoentry -lc
Packit bc69c3
    -L/usr/local/lib version.o DB_File.o  -o blib/arch/auto/DB_File/DB_File.so
Packit bc69c3
    -L/usr/local/BerkeleyDB/lib -ldb -lpthread
Packit bc69c3
    ld: 0711-317 ERROR: Undefined symbol: .mutex_lock
Packit bc69c3
    ld: 0711-317 ERROR: Undefined symbol: .cond_signal
Packit bc69c3
    ld: 0711-317 ERROR: Undefined symbol: .mutex_unlock
Packit bc69c3
    ld: 0711-317 ERROR: Undefined symbol: .mutex_trylock
Packit bc69c3
    ld: 0711-317 ERROR: Undefined symbol: .cond_wait
Packit bc69c3
    ld: 0711-317 ERROR: Undefined symbol: .mutex_init
Packit bc69c3
    ld: 0711-317 ERROR: Undefined symbol: .cond_init
Packit bc69c3
    ld: 0711-317 ERROR: Undefined symbol: .mutex_destroy
Packit bc69c3
    ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
Packit bc69c3
    make: 1254-004 The error code from the last command is 8.
Packit bc69c3
Packit bc69c3
Editing Makefile.PL, and changing the line 
Packit bc69c3
Packit bc69c3
    $LIBS .= " -lpthread" if $^O eq 'aix' ;
Packit bc69c3
Packit bc69c3
to this
Packit bc69c3
Packit bc69c3
    $LIBS .= " -lthread" if $^O eq 'aix' ;
Packit bc69c3
Packit bc69c3
fixed the problem.
Packit bc69c3
Packit bc69c3
Packit bc69c3
FEEDBACK
Packit bc69c3
========
Packit bc69c3
Packit bc69c3
General feedback/questions/bug reports can be sent to me at pmqs@cpan.org.
Packit bc69c3
Packit bc69c3
Alternatively, if you have Usenet access, you can try the
Packit bc69c3
comp.databases.berkeley-db or comp.lang.perl.modules groups.
Packit bc69c3
Packit bc69c3
Packit bc69c3
Packit bc69c3
How to report a problem with DB_File.
Packit bc69c3
-------------------------------------
Packit bc69c3
Packit bc69c3
When reporting any problem, I need the information requested below. 
Packit bc69c3
Packit bc69c3
 1. The *complete* output from running this
Packit bc69c3
Packit bc69c3
        perl -V
Packit bc69c3
Packit bc69c3
    Do not edit the output in any way. 
Packit bc69c3
    Note, I want you to run "perl -V" and NOT "perl -v".
Packit bc69c3
Packit bc69c3
    If your perl does not understand the "-V" option it is too
Packit bc69c3
    old. DB_File needs Perl version 5.00405 or better.
Packit bc69c3
Packit bc69c3
 2. The version of DB_File you have.
Packit bc69c3
    If you have successfully installed DB_File, this one-liner will
Packit bc69c3
    tell you:
Packit bc69c3
Packit bc69c3
       perl -e 'use DB_File; print qq{DB_File ver $DB_File::VERSION\n}'
Packit bc69c3
Packit bc69c3
    If you are running windows use this
Packit bc69c3
    
Packit bc69c3
       perl -e "use DB_File; print qq{DB_File ver $DB_File::VERSION\n}"
Packit bc69c3
Packit bc69c3
    If you haven't installed DB_File then search DB_File.pm for a line
Packit bc69c3
    like this:
Packit bc69c3
Packit bc69c3
      $VERSION = "1.20" ;
Packit bc69c3
Packit bc69c3
 3. The version of Berkeley DB used to build DB_File and the version
Packit bc69c3
    that is used at runtime. (These are usually the same)
Packit bc69c3
Packit bc69c3
    If you are using a version older than 1.85, think about upgrading. One
Packit bc69c3
    point to note if you are considering upgrading Berkeley DB - the
Packit bc69c3
    file formats for 1.85, 1.86, 2.0, 3.0 & 3.1 are all different.
Packit bc69c3
Packit bc69c3
    If you have successfully installed DB_File, these commands will display
Packit bc69c3
    the versions I need
Packit bc69c3
Packit bc69c3
       perl -MDB_File -e 'print qq{Built with Berkeley DB ver $DB_File::db_ver\n}'
Packit bc69c3
       perl -MDB_File -e 'print qq{Running with Berkeley DB ver $DB_File::db_version\n}'
Packit bc69c3
Packit bc69c3
    If you are running windows use this
Packit bc69c3
Packit bc69c3
       perl -e "use DB_File; print qq{Built with Berkeley DB ver $DB_File::db_ver\n}"
Packit bc69c3
       perl -e "use DB_File; print qq{Running Berkeley DB ver $DB_File::db_version\n}"
Packit bc69c3
    
Packit bc69c3
 4. A copy the file config.in from the DB_File main source directory.
Packit bc69c3
Packit bc69c3
 5. A listing of directories where Berkeley DB is installed.
Packit bc69c3
    For example, if Berkeley DB is installed in /usr/BerkeleDB/lib and
Packit bc69c3
    /usr/BerkeleyDB/include, I need the output from running this
Packit bc69c3
Packit bc69c3
        ls -l /usr/BerkeleyDB/lib
Packit bc69c3
        ls -l /usr/BerkeleyDB/include
Packit bc69c3
Packit bc69c3
 6. If you are having problems building DB_File, send me a complete log
Packit bc69c3
    of what happened. Start by unpacking the DB_File module into a fresh
Packit bc69c3
    directory and keep a log of all the steps
Packit bc69c3
Packit bc69c3
        [edit config.in, if necessary]
Packit bc69c3
        perl Makefile.PL
Packit bc69c3
        make 
Packit bc69c3
        make test TEST_VERBOSE=1
Packit bc69c3
Packit bc69c3
 7. Now the difficult one. If you think you have found a bug in DB_File
Packit bc69c3
    and you want me to fix it, you will *greatly* enhance the chances
Packit bc69c3
    of me being able to track it down by sending me a small
Packit bc69c3
    self-contained Perl script that illustrates the problem you are
Packit bc69c3
    encountering. Include a summary of what you think the problem is
Packit bc69c3
    and a log of what happens when you run the script, in case I can't
Packit bc69c3
    reproduce your problem on my system. If possible, don't have the
Packit bc69c3
    script dependent on an existing 20Meg database. If the script you
Packit bc69c3
    send me can create the database itself then that is preferred.
Packit bc69c3
Packit bc69c3
    I realise that in some cases this is easier said than done, so if
Packit bc69c3
    you can only reproduce the problem in your existing script, then
Packit bc69c3
    you can post me that if you want. Just don't expect me to find your
Packit bc69c3
    problem in a hurry, or at all. :-)
Packit bc69c3
Packit bc69c3
Packit bc69c3
CHANGES
Packit bc69c3
-------
Packit bc69c3
Packit bc69c3
See the Changes file.
Packit bc69c3
Packit bc69c3
Paul Marquess <pmqs@cpan.org>