下载页面:
http://dev.sleepycat.com/downloads/releasehistorybdb.html
我使用的是当前最新版的4.5.20(点击下载)。
linux:/home/work/db # ll 总用量 9078 drwxr-xr-x 2 root root 80 2006-10-08 12:36 . drwxr-xr-x 11 root root 1120 2006-10-08 12:33 .. -r-xr-xr-x 1 root users 9281894 2006-10-08 12:36 db-4.5.20.tar.gz
(一)解压
linux:/home/work/db # tar -zxf db-4.5.20.tar.gz linux:/home/work/db # cd db-4.5.20/ linux:/home/work/db/db-4.5.20 # ls . db_checkpoint db_upgrade libdb_java README .. db_deadlock db_verify LICENSE rep btree db_dump dist lock repmgr build_unix db_dump185 docs log rpc_client build_vxworks db_hotbackup env mod_db4 rpc_server build_windows dbinc examples_c mp sequence clib dbinc_auto examples_cxx mutex tcl common db_load examples_java os test crypto dbm fileops os_vxworks txn cxx db_printlog hash os_windows xa db db_recover hmac perl db185 dbreg hsearch php_db4 db_archive db_stat java qam
docs目录下有我们需要的文档,包括快速入门、各种语言的API手册等资料。
(二)配置和编译
建立一个脚本以方便配置。由于unix/linux编译时的工作路径必须是build_unix,因此我们需要在build_unix目录下创建脚本。
我创建了一个名为myconfig的脚本,内容如下:
linux:/home/work/db/db-4.5.20/build_unix # cat -n myconfig
1 #!/bin/sh
2
3 CC=arm-elf-gcc
4 CFLAGS="-Os -D__uClinux__ -fno-builtin -I/home/uClinux-dist/linux-2.4.x/include -I/home/uClinux-dist/lib/uClibc/include -I/home/uClinux-dist/lib/uClibc/include/../ "
5 LDFLAGS="-Wl,-elf2flt -Wl,-move-rodata -L/home/uClinux-dist/lib/uClibc/lib -L/home/uClinux-dist/lib/uClibc/lib/../ -lc "
6 ../dist/configure
7 --prefix=/home/work/db/Berkeley.DB
8 --build=i686-linux
9 --host=arm-elf-linux
10 --disable-cryptography
11 --disable-hash
12 --disable-queue
13 --disable-replication
14 --disable-statistics
15 --disable-verify
16 --disable-compat185
17 --disable-cxx
18 --disable-debug
19 --disable-debug_rop
20 --disable-debug_wop
21 --disable-diagnostic
22 --disable-dump185
23 --disable-java
24 --disable-mingw
25 --disable-o_direct
26 --disable-posixmutexes
27 --disable-pthread_api
28 --disable-rpc
29 --disable-smallbuild
30 --disable-tcl
31 --disable-test
32 --disable-uimutexes
33 --enable-umrw
34 --disable-shared
35 --enable-static
36 --enable-fast-install
37 --disable-libtool-lock
38 --disable-largefile
关于configure配置参数的含义,可以运行”../dist/configure –help”查看帮助,这里不再介绍。
要强调的一点是uClibc只能用静态编译,因此一定要选择–disable-shared。
接着执行./myconfig运行配置并编译安装函数库:
linux:/home/work/db/db-4.5.20/build_unix # ./myconfig >/dev/null configure: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org. cat: /etc/ld.so.conf.d/*.conf: No such file or directory linux:/home/work/db/db-4.5.20/build_unix # make >/dev/null && make install >/dev/null ../dist/../hmac/sha1.c:96: warning: `R0' redefined /usr/local/lib/gcc-lib/arm-elf/2.95.3/../../../../arm-elf/include/sys/ucontext.h:40: warning: this is the location of the previous definition ../dist/../hmac/sha1.c:97: warning: `R1' redefined /usr/local/lib/gcc-lib/arm-elf/2.95.3/../../../../arm-elf/include/sys/ucontext.h:42: warning: this is the location of the previous definition ../dist/../hmac/sha1.c:98: warning: `R2' redefined /usr/local/lib/gcc-lib/arm-elf/2.95.3/../../../../arm-elf/include/sys/ucontext.h:44: warning: this is the location of the previous definition ../dist/../hmac/sha1.c:99: warning: `R3' redefined /usr/local/lib/gcc-lib/arm-elf/2.95.3/../../../../arm-elf/include/sys/ucontext.h:46: warning: this is the location of the previous definition ../dist/../hmac/sha1.c:100: warning: `R4' redefined /usr/local/lib/gcc-lib/arm-elf/2.95.3/../../../../arm-elf/include/sys/ucontext.h:48: warning: this is the location of the previous definition warning: .rodata section contains relocations warning: .rodata section contains relocations warning: .rodata section contains relocations warning: .rodata section contains relocations warning: .rodata section contains relocations warning: .rodata section contains relocations warning: .rodata section contains relocations warning: .rodata section contains relocations warning: .rodata section contains relocations warning: .rodata section contains relocations warning: .rodata section contains relocations strip: /home/work/db/Berkeley.DB/bin/db_archive: 不可识别的文件格式 strip: /home/work/db/Berkeley.DB/bin/db_checkpoint: 不可识别的文件格式 strip: /home/work/db/Berkeley.DB/bin/db_deadlock: 不可识别的文件格式 strip: /home/work/db/Berkeley.DB/bin/db_dump: 不可识别的文件格式 strip: /home/work/db/Berkeley.DB/bin/db_hotbackup: 不可识别的文件格式 strip: /home/work/db/Berkeley.DB/bin/db_load: 不可识别的文件格式 strip: /home/work/db/Berkeley.DB/bin/db_printlog: 不可识别的文件格式 strip: /home/work/db/Berkeley.DB/bin/db_recover: 不可识别的文件格式 strip: /home/work/db/Berkeley.DB/bin/db_stat: 不可识别的文件格式 strip: /home/work/db/Berkeley.DB/bin/db_upgrade: 不可识别的文件格式 strip: /home/work/db/Berkeley.DB/bin/db_verify: 不可识别的文件格式
