TokyoCabinet安装使用过程问题集
2013-03-19 19:55:07 阿炯

-------------------
tokyocabinet-1.4安装时缺库报错
./configure会出现如下错误:

checking bzlib.h usability... no
checking bzlib.h presence... no
checking for bzlib.h... no
configure: error: bzlib.h is required

这是系统中没有安装'bzlib'库的开发包头所导致的,首先应该安装其。它是常用压缩软件bzip2的开发包,我们找一下:
# apt-cache search bzip2

在系列结果中可以找到其名称:libbz2-dev

但是出现新的错误libbz2-dev: Depends: libbz2-1.0 (= 1.0.5-1) but 1.0.5-3 is to be installed E: Broken package,
这里需要通过apt-file可以找到该头文件属于那一个软件包。

# aptitude install apt-file
安装好后后提示更新缓存清单:
The system-wide cache is empty. You may want to run 'apt-file update'
as root to update the cache. You can also run 'apt-file update' as
normal user to use a cache in the user's home directory.

更新包文件cache
apt-file update
Downloading complete file http://ftp.cn.debian.org/debian/dists/squeeze/Contents-i386.gz

'Contents-i386.gz'文件包含了所有通过官方deb包中所有的文件,这样通过找具体文件可反知其所在的软件包。

查找bzlib.h属于哪一个软件包
apt-file search bzlib.h
会得到:
libbz2-dev: /usr/include/bzlib.h
libcomplearn1-headers: /usr/include/complearn-1.0/complearn/complearn-rcbzlib.h
libghc6-bzlib-dev: /usr/lib/ghc-6.12.1/haddock/bzlib-0.5.0.0/bzlib.haddock

很显然,它最应属于开发包头文件:
aptitude install libbz2-dev
安装完成以后,再回到上面去配置tc,ok,安装tc成功。

在centos下,可以通过yum进行安装。
# yum install bzip2-devel

另注:在32位Linux操作系统上编译Tokyo cabinet,请使用./configure --enable-off64代替./configure,可以使数据库文件突破2GB的限制。

-------------------
访问错误
open error: stat error
open error: invalid meta data
close error: stat error

这种现象出现在库文件存放在windows samba共享服上,在linux上通过mount挂载过来,在上面跑脚本,就会报上页错误提示。当将其移至本地目录时,则没有这个现象,估计是它对文件系统有要求,不能取得某些信息而导致的吧。

-------------------
缺少'lz'包

使用cpanp编译时的报错:
Running Mkbootstrap for TokyoCabinet ()
chmod 644 TokyoCabinet.bs
rm -f blib/arch/auto/TokyoCabinet/TokyoCabinet.so
LD_RUN_PATH="/usr/lib64:/lib/../lib64" cc  -shared -O2 -L/usr/local/lib -fstack-protector TokyoCabinet.o  -o blib/arch/auto/TokyoCabinet/TokyoCabinet.so     \
       -L/usr/lib64 -ltokyocabinet -lbz2 -lz -lrt -lpthread -lm -lc      \
      
/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make: *** [blib/arch/auto/TokyoCabinet/TokyoCabinet.so] Error 1

[ERROR] Unable to create a new distribution object for 'tokyocabinet::perl' -- cannot continue

*** Install log written to:
  /root/.cpanplus/install-logs/tokyocabinet-perl-1.34-1427423292.log

Error installing 'tokyocabinet::perl'
Problem installing one or more modules
*** You can view the complete error buffer by pressing 'p' ***

需要安装zlib-dev这个开发依赖包,通过安装命令为:apt-get install zlib1g-dev | yum install  zlib-devel

-------------------

-------------------