README
Upload User: tsgydb
Upload Date: 2007-04-14
Package Size: 10674k
Code Size: 17k
Category:

MySQL

Development Platform:

Visual C++

  1.                                    BerkeleyDB
  2.                                   Version 0.13
  3.                                   15th Jan 2001
  4. Copyright (c) 1997-2001 Paul Marquess. All rights reserved. This
  5. program is free software; you can redistribute it and/or modify
  6. it under the same terms as Perl itself.
  7. DESCRIPTION
  8. -----------
  9. BerkeleyDB is a module which allows Perl programs to make use of the
  10. facilities provided by Berkeley DB version 2 or 3. (Note: if you want
  11. to use version 1 of Berkeley DB with Perl you need the DB_File module).
  12. Berkeley DB is a C library which provides a consistent interface to a
  13. number of database formats. BerkeleyDB provides an interface to all
  14. four of the database types (hash, btree, queue and recno) currently
  15. supported by Berkeley DB.
  16. For further details see the documentation in the file BerkeleyDB.pod.
  17. PREREQUISITES
  18. -------------
  19. Before you can build BerkeleyDB you need to have the following
  20. installed on your system:
  21.     * Perl 5.004_04 or greater.
  22.     * Berkeley DB Version 2.6.4 or greater
  23.       The official web site for Berkeley DB is http://www.sleepycat.com
  24.       The latest version of Berkeley DB is always available there. It
  25.       is recommended that you use the most recent version available at
  26.       the Sleepycat site.
  27.       The one exception to this advice is where you want to use BerkeleyDB
  28.       to access database files created by a third-party application,
  29.       like Sendmail. In these cases you must build BerkeleyDB with a
  30.       compatible version of Berkeley DB.
  31. BUILDING THE MODULE
  32. -------------------
  33. Assuming you have met all the prerequisites, building the module should
  34. be relatively straightforward.
  35. Step 1 : If you are running Solaris 2.5, 2.7 or HP-UX 10 read either
  36.          the Solaris Notes or HP-UX Notes sections below.
  37.  If you are running Linux please read the Linux Notes section
  38.          before proceeding.
  39. Step 2 : Edit the file config.in to suit you local installation.
  40.          Instructions are given in the file.
  41. Step 3 : Build and test the module using this sequence of commands:
  42.              perl Makefile.PL
  43.              make
  44.              make test
  45. INSTALLATION
  46. ------------
  47.     make install
  48. TROUBLESHOOTING
  49. ===============
  50. Here are some of the problems that people encounter when building BerkeleyDB.
  51. Missing db.h or libdb.a
  52. -----------------------
  53. If you get an error like this:
  54.   cc -c -I./libraries/ -Dbool=char -DHAS_BOOL -I/usr/local/include -O2
  55.   -DVERSION="0.07" -DXS_VERSION="0.07" -fpic
  56.   -I/usr/local/lib/perl5/5.00503/i586-linux/CORE  BerkeleyDB.c
  57.   BerkeleyDB.xs:52: db.h: No such file or directory
  58. or this:
  59.   cc -c -I./libraries/2.7.5 -Dbool=char -DHAS_BOOL -I/usr/local/include -O2
  60.   -DVERSION="0.07" -DXS_VERSION="0.07" -fpic
  61.   -I/usr/local/lib/perl5/5.00503/i586-linux/CORE  BerkeleyDB.c
  62.   LD_RUN_PATH="/lib" cc -o blib/arch/auto/BerkeleyDB/BerkeleyDB.so  -shared
  63.   -L/usr/local/lib BerkeleyDB.o
  64.   -L/home/paul/perl/ext/BerkDB/BerkeleyDB/libraries -ldb
  65.   ld: cannot open -ldb: No such file or directory
  66. This symptom can imply:
  67.  1. You don't have Berkeley DB installed on your system at all.
  68.     Solution: get & install Berkeley DB.
  69.  2. You do have Berkeley DB installed, but it isn't in a standard place.
  70.     Solution: Edit config.in and set the LIB and INCLUDE variables to point
  71.               to the directories where libdb.a and db.h are installed.
  72. Wrong db.h
  73. ----------
  74. If you get an error like this when building this module:
  75.   cc -c -I./libraries/ -Dbool=char -DHAS_BOOL -I/usr/local/include -O2
  76.   -DVERSION="0.07" -DXS_VERSION="0.07" -fpic
  77.   -I/usr/local/lib/perl5/5.00503/i586-linux/CORE  BerkeleyDB.c
  78.   BerkeleyDB.xs:93: parse error before `DB_INFO'
  79.   BerkeleyDB.xs:93: warning: no semicolon at end of struct or union
  80.   BerkeleyDB.xs:94: warning: data definition has no type or storage class
  81.   BerkeleyDB.xs:95: parse error before `0x80000000'
  82.   BerkeleyDB.xs:110: parse error before `}'
  83.   BerkeleyDB.xs:110: warning: data definition has no type or storage class
  84.   BerkeleyDB.xs:117: parse error before `DB_ENV'
  85.   ...
  86. This error usually happens when if you only have Berkeley DB version 1
  87. on your system or you have both version 1 and version 2 (or 3) of Berkeley
  88. DB installed on your system. When building BerkeleyDB it attempts 
  89. to use the db.h for Berkeley DB version 1. This perl module can only
  90. be built with Berkeley DB version 2 or 3.
  91. This symptom can imply:
  92.  1. You don't have Berkeley DB version 2 or 3 installed on your system
  93.     at all.
  94.     Solution: get & install Berkeley DB.
  95.  2. You do have Berkeley DB 2 or 3 installed, but it isn't in a standard
  96.     place.
  97.     Solution: Edit config.in and set the LIB and INCLUDE variables
  98.               to point to the directories where libdb.a and db.h are
  99.               installed.
  100. Undefined Symbol: txn_stat 
  101. --------------------------
  102. BerkeleyDB seems to have built correctly, but you get an error like this
  103. when you run the test harness:
  104.   $ make test
  105.   PERL_DL_NONLAZY=1 /home/paul/perl/install/bin/perl5.00503
  106.   -Iblib/arch -Iblib/lib -I/usr/local/lib/perl5/5.00503/i586-linux
  107.   -I/usr/local/lib/perl5/5.00503 -e 'use Test::Harness qw(&runtests $verbose);
  108.   $verbose=0; runtests @ARGV;' t/*.t
  109.   t/btree.............Can't load 'blib/arch/auto/BerkeleyDB/BerkeleyDB.so' for
  110.   module BerkeleyDB: blib/arch/auto/BerkeleyDB/BerkeleyDB.so:
  111.   undefined symbol: txn_stat
  112.   at /usr/local/lib/perl5/5.00503/i586-linux/DynaLoader.pm line 169.
  113.   ...
  114. This error usually happens when you have both version 1 and version
  115. 2 (or 3) of Berkeley DB installed on your system and BerkeleyDB attempts
  116. to build using the db.h for Berkeley DB version 2/3 and the version 1
  117. library. Unfortunately the two versions aren't compatible with each
  118. other. BerkeleyDB can only be built with Berkeley DB version 2 or 3.
  119. Solution: Setting the LIB & INCLUDE variables in config.in to point to the
  120.           correct directories can sometimes be enough to fix this
  121.           problem. If that doesn't work the easiest way to fix the
  122.           problem is to either delete or temporarily rename the copies
  123.           of db.h and libdb.a that you don't want BerkeleyDB to use.
  124. Undefined Symbol: db_appinit 
  125. ----------------------------
  126. BerkeleyDB seems to have built correctly, but you get an error like this
  127. when you run the test harness:
  128.   $ make test
  129.   PERL_DL_NONLAZY=1 /home/paul/perl/install/bin/perl5.00561 -Iblib/arch 
  130.   -Iblib/lib -I/home/paul/perl/install/5.005_61/lib/5.00561/i586-linux 
  131.   -I/home/paul/perl/install/5.005_61/lib/5.00561 -e 'use Test::Harness 
  132.   qw(&runtests $verbose); $verbose=0; runtests @ARGV;' t/*.t
  133.   t/btree.............Can't load 'blib/arch/auto/BerkeleyDB/BerkeleyDB.so' for 
  134.   module BerkeleyDB: blib/arch/auto/BerkeleyDB/BerkeleyDB.so: 
  135.   undefined symbol: db_appinit 
  136.   at /home/paul/perl/install/5.005_61/lib/5.00561/i586-linux/DynaLoader.pm 
  137.   ...
  138. This error usually happens when you have both version 2 and version
  139. 3 of Berkeley DB installed on your system and BerkeleyDB attempts
  140. to build using the db.h for Berkeley DB version 2 and the version 3
  141. library. Unfortunately the two versions aren't compatible with each
  142. other. 
  143. Solution: Setting the LIB & INCLUDE variables in config.in to point to the
  144.           correct directories can sometimes be enough to fix this
  145.           problem. If that doesn't work the easiest way to fix the
  146.           problem is to either delete or temporarily rename the copies
  147.           of db.h and libdb.a that you don't want BerkeleyDB to use.
  148. Undefined Symbol: db_create
  149. ---------------------------
  150. BerkeleyDB seems to have built correctly, but you get an error like this
  151. when you run the test harness:
  152.   $ make test   
  153.   PERL_DL_NONLAZY=1 /home/paul/perl/install/bin/perl5.00561 -Iblib/arch 
  154.   -Iblib/lib -I/home/paul/perl/install/5.005_61/lib/5.00561/i586-linux 
  155.   -I/home/paul/perl/install/5.005_61/lib/5.00561 -e 'use Test::Harness 
  156.   qw(&runtests $verbose); $verbose=0; runtests @ARGV;' t/*.t
  157.   t/btree.............Can't load 'blib/arch/auto/BerkeleyDB/BerkeleyDB.so' for 
  158.   module BerkeleyDB: blib/arch/auto/BerkeleyDB/BerkeleyDB.so: 
  159.   undefined symbol: db_create 
  160.   at /home/paul/perl/install/5.005_61/lib/5.00561/i586-linux/DynaLoader.pm 
  161.   ...
  162. This error usually happens when you have both version 2 and version
  163. 3 of Berkeley DB installed on your system and BerkeleyDB attempts
  164. to build using the db.h for Berkeley DB version 3 and the version 2
  165. library. Unfortunately the two versions aren't compatible with each
  166. other. 
  167. Solution: Setting the LIB & INCLUDE variables in config.in to point to the
  168.           correct directories can sometimes be enough to fix this
  169.           problem. If that doesn't work the easiest way to fix the
  170.           problem is to either delete or temporarily rename the copies
  171.           of db.h and libdb.a that you don't want BerkeleyDB to use.
  172. Incompatible versions of db.h and libdb
  173. ---------------------------------------
  174. BerkeleyDB seems to have built correctly, but you get an error like this
  175. when you run the test harness:
  176.   $ make test
  177.   PERL_DL_NONLAZY=1 /home/paul/perl/install/bin/perl5.00503
  178.   -Iblib/arch -Iblib/lib -I/usr/local/lib/perl5/5.00503/i586-linux
  179.   -I/usr/local/lib/perl5/5.00503 -e 'use Test::Harness qw(&runtests $verbose);
  180.   $verbose=0; runtests @ARGV;' t/*.t
  181.   t/btree.............
  182.   BerkeleyDB needs compatible versions of libdb & db.h
  183.           you have db.h version 2.6.4 and libdb version 2.7.5
  184.   BEGIN failed--compilation aborted at t/btree.t line 25.
  185.   dubious
  186.         Test returned status 255 (wstat 65280, 0xff00)
  187.   ...
  188. Another variation on the theme of having two versions of Berkeley DB on
  189. your system. 
  190. Solution: Setting the LIB & INCLUDE variables in config.in to point to the
  191.           correct directories can sometimes be enough to fix this
  192.           problem. If that doesn't work the easiest way to fix the
  193.           problem is to either delete or temporarily rename the copies
  194.           of db.h and libdb.a that you don't want BerkeleyDB to use.
  195.   If you are running Linux, please read the Linux Notes section below.
  196. Linux Notes
  197. -----------
  198. Newer versions of Linux (e.g. RedHat 6, SuSe 6) ship with a C library
  199. that has version 2.x of Berkeley DB linked into it. This makes it
  200. difficult to build this module with anything other than the version of
  201. Berkeley DB that shipped with your Linux release. If you do try to use
  202. a different version of Berkeley DB you will most likely get the error
  203. described in the "Incompatible versions of db.h and libdb" section of
  204. this file.
  205. To make matters worse, prior to Perl 5.6.1, the perl binary itself
  206. *always* included the Berkeley DB library.
  207. If you want to use a newer version of Berkeley DB with this module, the
  208. easiest solution is to use Perl 5.6.1 (or better) and Berkeley DB 3.x
  209. (or better).
  210. There are two approaches you can use to get older versions of Perl to
  211. work with specific versions of Berkeley DB. Both have their advantages
  212. and disadvantages.
  213. The first approach will only work when you want to build a version of
  214. Perl older than 5.6.1 along with Berkeley DB 3.x. If you want to use
  215. Berkeley DB 2.x, you must use the next approach. This approach involves
  216. rebuilding your existing version of Perl after applying an unofficial
  217. patch. The "patches" directory in the this module's source distribution
  218. contains a number of patch files. There is one patch file for every
  219. stable version of Perl since 5.004. Apply the appropriate patch to your
  220. Perl source tree before re-building and installing Perl from scratch.
  221. For example, assuming you are in the top-level source directory for
  222. Perl 5.6.0, the command below will apply the necessary patch. Remember
  223. to replace the path shown below with one that points to this module's
  224. patches directory.
  225.     patch -p1 -N </path/to/BerkeleyDB/patches/5.6.0
  226. Now rebuild & install perl. You should now have a perl binary that can
  227. be used to build this module. Follow the instructions in "BUILDING THE
  228. MODULE", remembering to set the INCLUDE and LIB variables in config.in.
  229. The second approach will work with both Berkeley DB 2.x and 3.x.
  230. Start by building Berkeley DB as a shared library. This is from
  231. the Berkeley DB build instructions:
  232.     Building Shared Libraries for the GNU GCC compiler
  233.     If you're using gcc and there's no better shared library example for
  234.     your architecture, the following shared library build procedure will
  235.     probably work.
  236.     Add the -fpic option to the CFLAGS value in the Makefile.
  237.     Rebuild all of your .o files. This will create a Berkeley DB library
  238.     that contains .o files with PIC code. To build the shared library,
  239.     then take the following steps in the library build directory:
  240.     % mkdir tmp
  241.     % cd tmp
  242.     % ar xv ../libdb.a
  243.     % gcc -shared -o libdb.so *.o
  244.     % mv libdb.so ..
  245.     % cd ..
  246.     % rm -rf tmp
  247.     Note, you may have to change the gcc line depending on the
  248.     requirements of your system.
  249.     The file libdb.so is your shared library
  250. Once you have built libdb.so, you will need to store it somewhere safe.
  251.     cp libdb.so /usr/local/BerkeleyDB/lib
  252. If you now set the LD_PRELOAD environment variable to point to this
  253. shared library, Perl will use it instead of the version of Berkeley DB
  254. that shipped with your Linux distribution.
  255.     export LD_PRELOAD=/usr/local/BerkeleyDB/lib/libdb.so
  256. Finally follow the instructions in "BUILDING THE MODULE" to build,
  257. test and install this module. Don't forget to set the INCLUDE and LIB
  258. variables in config.in.
  259. Remember, you will need to have the LD_PRELOAD variable set anytime you
  260. want to use Perl with Berkeley DB. Also note that if you have LD_PRELOAD
  261. permanently set it will affect ALL commands you execute. This may be a
  262. problem if you run any commands that access a database created by the
  263. version of Berkeley DB that shipped with your Linux distribution.
  264. Solaris 2.5 Notes
  265. -----------------
  266. If you are running Solaris 2.5, and you get this error when you run the
  267. BerkeleyDB test harness:
  268.     libc internal error: _rmutex_unlock: rmutex not held.
  269. you probably need to install a Sun patch. It has been reported that
  270. Sun patch 103187-25 (or later revisions) fixes this problem.
  271. To find out if you have the patch installed, the command "showrev -p"
  272. will display the patches that are currently installed on your system.
  273. Solaris 2.7 Notes
  274. -----------------
  275. If you are running Solaris 2.7 and all the tests in the test harness
  276. generate a core dump, try applying Sun patch 106980-09 (or better).
  277. To find out if you have the patch installed, the command "showrev -p"
  278. will display the patches that are currently installed on your system.
  279. HP-UX Notes
  280. -----------
  281. Some people running HP-UX 10 have reported getting an error like this
  282. when building this module with the native HP-UX compiler.
  283.     ld: (Warning) At least one PA 2.0 object file (BerkeleyDB.o) was detected.
  284.     The linked output may not run on a PA 1.x system.
  285.     ld: Invalid loader fixup for symbol "$000000A5".
  286. If this is the case for you, Berkeley DB needs to be recompiled with
  287. the +z or +Z option and the resulting library placed in a .sl file. The
  288. following steps should do the trick:
  289.   1: Configure the Berkeley DB distribution with the +z or +Z C compiler
  290.      flag:
  291.         env "CFLAGS=+z" ../dist/configure ...
  292.   2: Edit the Berkeley DB Makefile and change:
  293.         "libdb= libdb.a" to "libdb= libdb.sl".
  294.   3: Build and install the Berkeley DB distribution as usual.
  295. FEEDBACK
  296. --------
  297. How to report a problem with BerkeleyDB.
  298. To help me help you, I need of the following information:
  299.  1. The version of Perl and the operating system name and version you
  300.     are running. The complete output from running "perl -V" will tell
  301.     me all I need to know.  
  302.     If your perl does not understand the "-V" option is too old.
  303.     BerkeleyDB needs Perl version 5.004_04 or better.
  304.  2. The version of BerkeleyDB you have. If you have successfully
  305.     installed BerkeleyDB, this one-liner will tell you:
  306.        perl -MBerkeleyDB -e 'print "BerkeleyDB ver $BerkeleyDB::VERSIONn"'
  307.     If you haven't installed BerkeleyDB then search BerkeleyDB.pm for a
  308.     line like this:
  309.       $VERSION = "1.20" ;
  310.  3. The version of Berkeley DB you have installed. If you have
  311.     successfully installed BerkeleyDB, this one-liner will tell you:
  312.         perl -MBerkeleyDB -e 'print BerkeleyDB::DB_VERSION_STRING."n"'
  313.     If you haven't installed BerkeleyDB then search db.h for a line
  314.     like this:
  315.       #define DB_VERSION_STRING
  316.  4. If you are having problems building BerkeleyDB, send me a complete
  317.     log of what happened.
  318.  5. Now the difficult one. If you think you have found a bug in
  319.     BerkeleyDB and you want me to fix it, you will *greatly* enhance
  320.     the chances of me being able to track it down by sending me a small
  321.     self-contained Perl script that illustrates the problem you are
  322.     encountering. Include a summary of what you think the problem is
  323.     and a log of what happens when you run the script, in case I can't
  324.     reproduce your problem on my system. If possible, don't have the
  325.     script dependent on an existing 20Meg database. If the script you
  326.     send me can create the database itself then that is preferred.
  327.     I realise that in some cases this is easier said than done, so if
  328.     you can only reproduce the problem in your existing script, then
  329.     you can post me that if you want. Just don't expect me to find your
  330.     problem in a hurry, or at all. :-)
  331. CHANGES
  332. -------
  333. See the Changes file.
  334. Paul Marquess <Paul.Marquess@btinternet.com>