现在的位置: 首页 > 综合 > 正文

windows下编译coreseek

2013年09月24日 ⁄ 综合 ⁄ 共 4815字 ⁄ 字号 评论关闭

一、介绍:

      Coreseek 是一款中文全文检索/搜索软件,以GPLv2许可协议开源发布,基于Sphinx研发并独立发布,专攻中文搜索和信息处理领域,适用于行业/垂直搜索、论坛/站内搜索、数据库搜索、文档/文献检索、信息检索、数据挖掘等应用场景。我们不仅可以免费下载使用,也可以对其提供的源代码进行修改,使其更符合我们的搜索要求。

二、编译环境:

      操作系统:windows 7 64/32位

      IDE:VS2008(vs2010会出现一个问题,不过需要在出错的文件中#include一个头文件,好像是vector.h,为了和官网的编译环境一致,减少错误,建议用vs2008)

      coreseek版本:coreseek-3.2.14和coreseek-4.1.2-beta

三、coreseek的代码结构

      不同版本有细微的差别,readme文件和博客http://blog.csdn.net/uestc_huan/article/details/6395174已经讲得很清楚了,在此不再赘述。

四、前期准备

      1、下载并安装mysql(http://downloads.mysql.com/archives/mysql-5.6/mysql-5.6.12-win32.msi);

      2、下载并安装LibExpat(http://garr.dl.sourceforge.net/project/expat/expat_win32/2.0.1/expat-win32bin-2.0.1.exe);

      3、下载并安装LibIConv (http://netcologne.dl.sourceforge.net/project/gnuwin32/libiconv/1.9.2-1/libiconv-1.9.2-1.exe);

      4、下载并安装python26(http://www.python.org/ftp/python/2.6/python-2.6.msi),本人现安装勒python33,出现了数据类型错误。

      假定所有的软件均安装在默认目录中。

五、源代码编译

      本人一共编译了两个版本:coreseek-3.2.14和coreseek-4.1.2-beta,两个版本编译略有区别:在编译coreseek-3.2.14之前,在libsphinx工程中,加入 py_helper.cpp(h) 、 py_layer.cpp(h) 、 py_source.cpp(h) 、 tokenizer_zhcn.cpp(h) 、 py_sphinx.c文件,这些文件在源代码工程中已经存在,不知何原因没有被加入到工程。接下来两个版本的编译情况一样。

sphinx.h 头文件定义(coreseek-3.2.14)

#define USE_MYSQL
1 /// whether to compile MySQL support
#define USE_PGSQL
0 /// whether to compile PgSQL support
#define USE_ODBC
0 /// whether to compile ODBC support
#define USE_LIBEXPAT
1 /// whether to compile libexpat support
#define USE_LIBICONV
1 /// whether to compile iconv support
#define USE_LIBXML
0 /// whether to compile libxml support
#define USE_LIBSTEMMER
0 /// whether to compile libstemmber support
#define USE_WINDOWS
1 /// whether to compile for Windows
#define USE_MMSEG
1 /// turn chinese segment on.
#define USE_CRFSEG
0 /// turn chinese segment on.
#define USE_PYTHON
1
#define USE_64BIT
0

sphinx.h 头文件定义(coreseek-4.1.2-beta)

#define USE_MYSQL 1
/// whether to compile MySQL support
#define USE_PGSQL 0
/// whether to compile PgSQL support
#define USE_ODBC 0
/// whether to compile ODBC support
#define USE_LIBEXPAT 1
/// whether to compile libexpat support
#define USE_LIBICONV 1
/// whether to compile iconv support
#define USE_LIBXML 0
/// whether to compile libxml support
#define USE_LIBSTEMMER
0 /// whether to compile libstemmber support
#define USE_WINDOWS 1
/// whether to compile for Windows
#define USE_MMSEG 1   /// enable mmseg
#define USE_SYSLOG 0
/// whether to use syslog for logging
#define UNALIGNED_RAM_ACCESS 1
#define USE_LITTLE_ENDIAN 1
#define USE_PYTHON              1       /// whether to compile Python support, NOTE:Coreseek Fork, this option must be on!
       #define USE_PYTHON_DEBUG                0 ///link to _d.lib or not
       #define USE_PYTHON_CASE_SENSIVE_ATTR            0 ///column case senstive @python

本人的sphinx.h中的配置如上。请根据自己要求将不需要支持的项注释掉。

      1、先把IDE模式调成release win32模式,否则会出现很多link错误。

      2、将所有工程的运行时库改成“多线程(/MT)”,具体:右键-》配置属性-》c/c++-》代码生成。此步非常重要,否则会出现link错误

      3、 添加mysql 的include路径(C:\Program Files (x86)\MySQL\MySQL Server 5.6\include) 到所有工程 (右击 - 属性- 配置属性 - C/C++ - 常规- 附加包含目录).

      4、添加mysql的lib路径(C:\Program Files (x86)\MySQL\MySQL Server 5.1\lib\opt) 到除 "libsphinx"之外的所有工程 (右击 - 属性- 配置属性 - 连接器- 常规-附加包含目录)

      5、添加LibExpat的路径(C:\Program Files (x86)\Expat 2.0.1\Bin)到除 "libsphinx"之外的所有工程 (右击 - 属性- 配置属性 - 连接器- 常规-附加包含目录)

      6、添加LibIConv 的路径(C:\Program Files (x86)\GnuWin32\lib)到除 "libsphinx"之外的所有工程 (右击 - 属性- 配置属性 - 连接器- 常规-附加包含目录)

      7、 添加python的include路径(C:\python26\include) 到所有工程 (右击 - 属性- 配置属性 - C/C++ - 常规- 附加包含目录).

      8、 添加mmseg(coreseek的源码中)的css路径({coreseek位置}\mmseg-3.2.14\src\css) 到所有工程 (右击 - 属性- 配置属性 - C/C++ - 常规- 附加包含目录).

      9、 添加mmseg(coreseek的源码中)的utils路径({coreseek位置}\mmseg-3.2.14\src\utils) 到所有工程 (右击 - 属性- 配置属性 - C/C++ - 常规- 附加包含目录).

      10、 添加mmseg(coreseek的源码中)的src路径({coreseek位置}\mmseg-3.2.14\src) 到所有工程 (右击 - 属性- 配置属性 - C/C++ - 常规- 附加包含目录).

      11、 添加expat的lib路径(C:\Program Files (x86)\Expat 2.0.1\Source\lib) 到所有工程 (右击 - 属性- 配置属性 - C/C++ - 常规- 附加包含目录).

      12、 添加LibIConv的Include路径(C:\Program Files (x86)\GnuWin32\include) 到所有工程 (右击 - 属性- 配置属性 - C/C++ - 常规- 附加包含目录).

      13、添加python的lib路径(C:\python26\libs)到除 "libsphinx"之外的所有工程 (右击 - 属性- 配置属性 - 连接器- 常规-附加包含目录)

      14、在网址http://download.csdn.net/detail/nextel/4577926下载iconv.lib,在coreseek的源文件夹src建文件夹lib,并将iconv.lib放入其中。

       15、打开libcss工程({coreseek目录}\mmseg-3.2.14\src\win32\libcss05.vcproj),改成release win32模式,并将该工程的运行时库改成“多线程(/MT)”,具体:右键-》配置属性-》c/c++-》代码生成。编译产生libcss.lib

      16、将产生的libcss.lib拷贝到14步中的lib文件夹中。

      17、添加第14步的lib路径到除 "libsphinx"之外的所有工程 (右击 - 属性- 配置属性 - 连接器- 常规-附加包含目录)

      18、编译成功!

      19、此还未完,若直接将产生的exe文件替换官网下载的编译好的exe文件,执行test_mysql.cmd,会出现WARNING: attribute 'date_added' not found - IGNORING警告,将mysql安装目录\lib\opt下的libmysql.dll替换coreseek-4.1-win32\bin下的libmysql.dll。运行成功!

      非常感谢博客http://happyboy200032.blog.163.com/blog/static/46903113201121361810137/的博主happyboy无私的帮助。coreseek技术负责人乔楚乔帮主给其他论坛的留言也让我受益匪浅。

参考网址:http://www.cppblog.com/AutomateProgram/archive/2012/02/13/165470.html

                    http://blog.csdn.net/e513479333/article/details/5420216

                    http://happyboy200032.blog.163.com/blog/static/46903113201121361810137/

                    http://www.coreseek.cn/forum/2_748_0.html

                    http://blog.csdn.net/uestc_huan/article/details/6395174

                    http://www.cnblogs.com/soli/archive/2008/10/23/1317313.html

抱歉!评论已关闭.