将开源clucene引擎编译成动态库

      本章介绍如何将clucene编译成动态库,开发桌面级的全文检索引擎。

      1.准备工具

        编译平台:windows 10

        代码编译工具:vs2010

        CMake版本:cmake-3.17.1-win64-x64

        源代码版本:clucene-core-2.3.3.4

        Zlib版本:zlib-1.2.3.exe

      2.安装zlib

       这里安装zlib只是为了方便,不用再去编译zlib库到引擎源码中,当然也可以自己去编译,安装完成之后,在安装的bin目录     (C:\Program Files (x86)\GnuWin32\bin)会生成只有一个zlib1.dll动态链接库,这个库待会使用。

        

     3.CMake编译项目

      首先解压源代码clucene-core-2.3.3.4.tar,然后解压cmake-3.17.1-win64-x64.zip工具,然后找到bin目录下的cmake-gui.exe工       具,双击执行,如图所示:

     

     然后找到源代码目录,新建一个win32的文件夹,主要是用于存放CMake生成的vs项目工程文件,

      

      在生成之前,首先需要在vs的库中添加一个头文件,因为源代码中引用的这个头文件,该头文件为linux中使用的,windows中没有,新建一个文件头,名称为:unistd.h内容为:

      

      然后将该文件放到对应版本的vs安装目录的include中,如图所示:

       

     然后在CMake工具中配置源代码路径信息,如图:

     

      然后在点击config,选择生成的目标编译工具。

      

      然后点击完成,开始配置,需要等几分钟,如图:

      

      然后我们点击generate,生成项目文件,生成之后找到我们创建的win32目录下就看到我们对应的vs项目文件了,如图:

       

       然后就可以用vs进行打开,但是这个项目代码的路径是不能移动的,CMake是根据绝对路径去生成的,移动之后,vs就找不到相应的路径。这可能是CMake的一个BUG。

      4.修改项目BUG

       修改项目中的BUG,找到demo项目,然后打开,如图:

        

        

        然后依次编译clucene-shared、clucene-core、cl_demo项目,在编译cl_demo项目之前,修改修改一下源代码,不然检索的时候不能定位文件。

        

        改完之后,然后开始编译,然后运行demo项目,在运行demo项目会报错,因为找不到zlib1.dll,找到之前我们安装的zlib的bin目录,然后将zlib1.dll拷贝到生成目录,如图:

        
      然后再次运行demo项目,如图:

      

      

      第一次是让我们输入将要被建立索引的原始内容所在的目录,这个目录我放了三个文本文件,如图:

      

       

     Demo项目会读取这三个文件的内容然后建立索引。

     第二次输入为建立索引的目录,demo会自动创建索引,如图:

      

      然后我们可以开始搜索测试

      

      可以看到根据我们搜索的内容然后查找到对应的文件。

      编译动态库到此讲解完毕,下一节我们讲解如何编译静态库,编译静态库需要修改项目配置,也可能是项目上遗留的BUG。Z转载请注明原文地址,编写博客不容易。

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
大名鼎鼎的clucene,是lucene的c++ 版; CLucene README ============== ------------------------------------------------------ CLucene is a C++ port of Lucene. It is a high-performance, full-featured text search engine written in C++. CLucene is faster than lucene as it is written in C++. ------------------------------------------------------ CLucene has contributions from many, see AUTHORS CLucene is distributed under the GNU Lesser General Public License (LGPL) *or* the Apache License, Version 2.0 See the LGPL.license and APACHE.license for the respective license information. Read COPYING for more about the license. Installation ------------ * For Linux, MacOSX, cygwin and MinGW build information, read INSTALL. * Boost.Jam files are provided in the root directory and subdirectories. * Microsoft Visual Studio (6&7) are provided in the win32 folder. Mailing List ------------ Questions and discussion should be directed to the CLucene mailing list at clucene[email protected] Find subscription instructions at http://lists.sourceforge.net/lists/listinfo/clucene-developers Suggestions and bug reports can be made on our bug tracking database (http://sourceforge.net/tracker/?group_id=80013&atid=558446) The latest version ------------------ Details of the latest version can be found on the CLucene sourceforge project web site: http://www.sourceforge.net/projects/clucene Documentation ------------- Documentation is provided at http://clucene.sourceforge.net/doc/doxygen/html/ You can also build your own documentation by running doxygen from the root directory of clucene. CLucene is a very close port of Java Lucene, so you can also try looking at the Java Docs on http://lucene.apache.org/java/ Performance ----------- Very little benchmarking has been done on clucene. Andi Vajda posted some limited statistics on the clucene list a while ago with the following results. There are 250 HTML files under $JAVA_HOME/docs/api/java/util for about 6108kb of HTML

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

落寞书生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值