CentOS下中文检索引擎coreseek(中文版sphinx)的编译安装
  在 Linux 分类下   409 条评论

CentOS下中文检索引擎coreseek(中文版sphinx)的编译安装

  在 Linux 分类下   409 条评论

安装依赖包

yum install make gcc g++ gcc-c++ libtool autoconf automake imake mysql-devel libxml2-devel expat-devel

安装分词工具mmseg

cd coreseek-4.1-beta
cd mmseg-3.2.14
./bootstrap
./configure --prefix=/usr/local/mmseg
make && make install

安装coreseek(sphinx)

生成配置文件

cd ../csft-4.1

执行./buildconf.sh生成配置文件,但直接执行会报如下错误:

automake: warnings are treated as errors

需要先修改文件configure.ac,找到AC_PROG_RANLIB,后面加上AM_PROG_AR,最终格式为:AC_PROG_RANLIB AM_PROG_AR。再次执行 ./buildconf.sh

如果报错如下

configure.ac:61: error: required file 'config/ar-lib' not found
configure.ac:61:   'automake --add-missing' can install 'ar-lib'

则执行命令automake --add-missing,然后再次执行./buildconf.sh即可生成配置文件。

修改配置文件

vim +1746 src/sphinxexpr.cpp  # 打开src目录下的sphinxexpr.cpp文件并跳转到1746行

1746行    T val = ExprEval ( this->m_pArg, tMatch );
修改为    T val = this->ExprEval ( this->m_pArg, tMatch );

1777行    T val = ExprEval ( this->m_pArg, tMatch );
修改为    T val = this->ExprEval ( this->m_pArg, tMatch );

1823行    T val = ExprEval ( this->m_pArg, tMatch );
修改为    T val = this->ExprEval ( this->m_pArg, tMatch );

不然会在编译时报如下错误:

sphinxexpr.cpp:1823:43: 错误:‘ExprEval’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
   T val = ExprEval ( this->m_pArg, tMatch ); // 'this' fixes gcc braindamage

编译安装

./configure --prefix=/usr/local/coreseek --without-python --without-unixodbc --with-mmseg --with-mmseg-includes=/usr/local/mmseg/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg/lib/ --with-mysql

make && make install

其它错误

如果在编译过程中报如下错误

/usr/local/src/coreseek-4.1-beta/src/sphinx.cpp:26852: undefined reference to `libiconv_open'
/usr/local/src/coreseek-4.1-beta/src/sphinx.cpp:26870: undefined reference to `libiconv'
/usr/local/src/coreseek-4.1-beta/src/sphinx.cpp:26876: undefined reference to `libiconv_close'

原因是g++没有添加 -libiconv选项

vim src/Makefile
/LIBS        #搜索LIBS
LIBS = -ldl -lm -lz -lexpat  -L/usr/local/lib -lrt  -lpthread 后面加上-liconv
最终格式为
LIBS = -ldl -lm -lz -lexpat  -L/usr/local/lib -lrt  -lpthread -liconv

再次安装即可

评论已关闭