recoll的windows版本编译指南

  • 时间:2025-11-13 20:44 作者: 来源: 阅读:3
  • 扫一扫,手机访问
摘要:1、编译环境 安装MSYS2环境,参考【MSYS2】MSYS2 安装指南_msys2安装-CSDN博客https://blog.csdn.net/weixin_43219667/article/details/153396525 2、下载源码 从https://www.recoll.org/recoll-1.43.7.tar.gz下载源码。 或者: 从https://github.com

1、编译环境

安装MSYS2环境,参考【MSYS2】MSYS2 安装指南_msys2安装-CSDN博客https://blog.csdn.net/weixin_43219667/article/details/153396525

2、下载源码

从https://www.recoll.org/recoll-1.43.7.tar.gz下载源码。

或者:

从https://github.com/brianonn/recoll.git进行git clone。

3、编译步骤

3.1、解压

        在home目录执行tar -zxvf recoll-1.43.7.tar.gz

3.2、调整

        1)修改src/meson.build



# git diff meson.build
diff --git a/src/meson.build b/src/meson.build
index 5dc00caf..7471185f 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -29,7 +29,7 @@ project(
     version: '1.43.2', # VERSIONCOMMENT keep this here, used by setversion.sh
     # Note: follow_symlinks will be needed in the future but not supported by all the versions we
     # need at the moment
-    default_options: ['cpp_std=c++17', 'buildtype=debugoptimized',
+    default_options: ['cpp_std=c++17', 'buildtype=release',
                        #'follow_symlinks=true'
                      ],
     meson_version: '>=0.60',
@@ -51,6 +51,8 @@ cc = meson.get_compiler('c')
 libxml = dependency('libxml-2.0')
 libxslt =  dependency('libxslt')
 libz = dependency('zlib')
+libregex = dependency('regex')
+libshlwapi = cpp.find_library('shlwapi', required:true)
 if get_option('libmagic')
     libmagic = dependency('libmagic', required:false)
     # Libmagic has no pkgconfig data on older debian systems
@@ -72,6 +74,8 @@ if get_option('testmains') or get_option('python-module') or get_option('indexer
     librecolldeps += libxml
     librecolldeps += libxslt
     librecolldeps += libz
+    librecolldeps += libregex
+    librecolldeps += libshlwapi
     if get_option('libmagic')
         librecolldeps += libmagic
     endif
@@ -98,6 +102,10 @@ recoll_datadir = get_option('prefix') / get_option('datadir') / 'recoll'
 
 defineslist =     [
         '-DBUILDING_RECOLL',
+        '-DWIN32',
+        '-D__WIN32__',
+        '-DUNICODE',
+        '-D_UNICODE',
         '-DREADFILE_ENABLE_ZLIB',
         '-DREADFILE_ENABLE_MINIZ',
         '-DREADFILE_ENABLE_MD5',
@@ -281,7 +289,7 @@ librecoll_sources = [
     'common/unacpp.cpp',
     'common/webstore.cpp',
     'index/webqueuefetcher.cpp',
-    'index/checkretryfailed.cpp',
+    #'index/checkretryfailed.cpp',
     'index/exefetcher.cpp',
     'index/fetcher.cpp',
     'index/fsfetcher.cpp',
@@ -345,7 +353,7 @@ librecoll_sources = [
     'utils/copyfile.cpp',
     'utils/cpuconf.cpp',
     'utils/ecrontab.cpp',
-    'utils/execmd.cpp',
+    #'utils/execmd.cpp',
     'utils/fileudi.cpp',
     'utils/fstreewalk.cpp',
     'utils/hldata.cpp',
@@ -356,7 +364,7 @@ librecoll_sources = [
     'utils/md5ut.cpp',
     'utils/mimeparse.cpp',
     'utils/miniz.cpp',
-    'utils/netcon.cpp',
+    #'utils/netcon.cpp',
     'utils/pathut.cpp',
     'utils/powerstatus.cpp',
     'utils/pxattr.cpp',
@@ -369,12 +377,19 @@ librecoll_sources = [
     'utils/wipedir.cpp',
     'utils/x11mon.cpp',
     'utils/zlibut.cpp',
+    'windows/execmd_w.cpp',
+    'windows/fnmatch.c',
+    #'windows/getopt.cc',
+    #'windows/rclstartw.cpp',
+    'windows/strptime.cpp',
+    'windows/wincodepages.cpp',
 ]
 
 if host_machine.system() == 'darwin'
     librecoll_sources += 'internfile/finderxattr.cpp'
 endif
 librecoll_incdir = include_directories(
+    'windows',
     'aspell',
     'bincimapmime',
     'common',
(END)

         2)修改src/qtgui/meson.build



# git diff src/qtgui/meson.build
diff --git a/src/qtgui/meson.build b/src/qtgui/meson.build
index cbb42481..55d69a50 100644
--- a/src/qtgui/meson.build
+++ b/src/qtgui/meson.build
@@ -53,7 +53,7 @@ recoll = custom_target(
     'recoll',
     output: outfile,
     input: infile,
-    command: [qmkmk, '@INPUT@', prefixoption],
+    command: [qmkmk, meson.current_source_dir() / 'recoll-win.pro', prefixoption],
     depends: librecoll,
     install: true,
     install_dir: 'bin',

         3)增加src/qtgui/recoll-win.pro

        拷贝src/qtgui/recoll.pro.in为src/qtgui/recoll-win.pro,并增加



# diff src/qtgui/recoll.pro.in src/qtgui/recoll-win.pro
164a165,168
>   SOURCES += ../wingetopt/getopt.cc
>
>   LIBS += ../build/librecoll.dll.a
>
 
@@ -138,11 +138,11 @@ windows {
 
   include(singleapplication.pri)
 
-  # QT += webkit webkitwidgets
-  # DEFINES += USING_WEBKIT
+  QT += webkit webkitwidgets
+  DEFINES += USING_WEBKIT
 
-  QT += widgets webenginewidgets
-  DEFINES += USING_WEBENGINE
+  # QT += widgets webenginewidgets
+  # DEFINES += USING_WEBENGINE
 
   DEFINES += PSAPI_VERSION=1
   DEFINES += __WIN32__

         4)新建src/wingetopt目录

         移动src/windows/getopt.cc和getopt.h文件到src/wingetopt目录下,使得getopt只在qtgui中使用。

        5)修改src/common/rclutil.cpp



# git diff src/common/rclutil.cpp
diff --git a/src/common/rclutil.cpp b/src/common/rclutil.cpp
index 0fa70ddc..a03fc83f 100644
--- a/src/common/rclutil.cpp
+++ b/src/common/rclutil.cpp
@@ -50,6 +50,7 @@
 
 #include <mutex>
 #include <map>
+#include <list>
 #include <unordered_map>
 #include <vector>
 #include <numeric>

        6)修改src/index/recollindex.cpp和src/index/recollindex.h



# git diff src/index/recollindex.cpp src/index/recollindex.h
diff --git a/src/index/recollindex.cpp b/src/index/recollindex.cpp
index 5f0733ae..abc32ef5 100644
--- a/src/index/recollindex.cpp
+++ b/src/index/recollindex.cpp
@@ -962,3 +962,51 @@ int main(int argc, char *argv[])
     }
     return !status;
 }
+
+bool checkRetryFailed(RclConfig *conf, bool record)
+{
+#ifdef _WIN32
+    PRETEND_USE(record);
+    // Under Windows we only retry if the recollindex program is newer than the index
+    struct PathStat st;
+    string path(thisprog);
+    if (path_suffix(path).empty()) {
+        path = path + ".exe";
+    }
+    if (path_fileprops(path, &st) != 0) {
+        LOGERR("checkRetryFailed: can't stat the program file: " << thisprog << "
");
+        return false;
+    }
+    time_t exetime = st.pst_mtime;
+    if (path_fileprops(conf->getDbDir(), &st) != 0) {
+        // Maybe it just does not exist.
+        LOGDEB("checkRetryFailed: can't stat the index directory: " << conf->getDbDir() << "
");
+        return false;
+    }
+    time_t dbtime = st.pst_mtime;
+    return exetime > dbtime;
+#else
+    string cmd;
+
+    if (!conf->getConfParam("checkneedretryindexscript", cmd)) {
+        LOGDEB("checkRetryFailed: 'checkneedretryindexscript' not set in config
");
+        // We could toss a dice ? Say no retry in this case.
+        return false;
+    }
+
+    // Look in the filters directory (ies). If not found execpath will
+    // be the same as cmd, and we'll let execvp do its thing.
+    string execpath = conf->findFilter(cmd);
+
+    vector<string> args;
+    if (record) {
+        args.push_back("1");
+    }
+    ExecCmd ecmd;
+    int status = ecmd.doexec(execpath, args);
+    if (status == 0) {
+        return true;
+    }
+    return false;
+#endif
+}
diff --git a/src/index/recollindex.h b/src/index/recollindex.h
index 18489a80..2d85cb7a 100644
--- a/src/index/recollindex.h
+++ b/src/index/recollindex.h
@@ -45,4 +45,15 @@ class ReExec;
 extern ReExec *o_reexec;
 extern std::string thisprog;
 
+/** Check if retrying failed files may be needed. We execute a
+    shell-script for this. The default one checks if any of the common
+    bin directories changed.
+
+    @param conf the config
+    @param record if true, record the state instead of testing
+
+    @return true if retrying should be performed
+*/
+bool checkRetryFailed(RclConfig *conf, bool record);
+
 #endif /* _recollindex_h_included_ */

        7 )修改src/utils/log.cpp src/utils/miniz.cpp src/utils/pathut.cpp src/utils/readfile.h src/utils/smallut.h



# git diff src/utils/log.cpp src/utils/miniz.cpp src/utils/pathut.cpp src/utils/readfile.h src/utils/smallut.h
diff --git a/src/utils/log.cpp b/src/utils/log.cpp
index 3cea9263..a3a703f6 100644
--- a/src/utils/log.cpp
+++ b/src/utils/log.cpp
@@ -21,7 +21,7 @@
 #include <fstream>
 #include <time.h>
 
-#ifdef _MSC_VER
+#ifdef _WIN32
 #define localtime_r(A,B) localtime_s(B,A)
 #endif
 
diff --git a/src/utils/miniz.cpp b/src/utils/miniz.cpp
index d4ca1350..fb6db374 100644
--- a/src/utils/miniz.cpp
+++ b/src/utils/miniz.cpp
@@ -3871,7 +3871,8 @@ mz_bool mz_zip_reader_init_file_v2(mz_zip_archive *pZip, const WCHAR_TYPE *pFile
     if ((!pZip) || (!pFilename) || ((archive_size) && (archive_size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE)))
         return mz_zip_set_error(pZip, MZ_ZIP_INVALID_PARAMETER);
 #ifdef _WIN32
-    pFile = MZ_FOPENREAD(pFilename, L"rb");
+    // pFile = MZ_FOPENREAD(pFilename, L"rb");
+    pFile = MZ_FOPENREAD((const char *)pFilename, "rb");
 #else
     pFile = MZ_FOPENREAD(pFilename, "rb");
 #endif
diff --git a/src/utils/pathut.cpp b/src/utils/pathut.cpp
index e9e1e05c..52a298e9 100644
--- a/src/utils/pathut.cpp
+++ b/src/utils/pathut.cpp
@@ -82,7 +82,7 @@
 #define WINVER 0x0601
 #undef _WIN32_WINNT
 #define _WIN32_WINNT 0x0601
-#define LOGFONTW void
+// #define LOGFONTW void
 #endif
 
 #ifndef NOMINMAX
diff --git a/src/utils/readfile.h b/src/utils/readfile.h
index 5516a51e..1eb3b666 100644
--- a/src/utils/readfile.h
+++ b/src/utils/readfile.h
@@ -19,6 +19,7 @@
 
 #include <sys/types.h>
 
+#include <cstdint>
 #include <string>
 
 class FileScanUpstream;
diff --git a/src/utils/smallut.h b/src/utils/smallut.h
index 34b97d64..eda7f1ef 100644
--- a/src/utils/smallut.h
+++ b/src/utils/smallut.h
@@ -94,8 +94,8 @@ bool wchartoutf8(const wchar_t *in, std::string& out, int len = 0);
 std::string wchartoutf8(const wchar_t *in, int len = 0);
 bool utf8towchar(const std::string& in, wchar_t *out, int obytescap);
 std::unique_ptr<wchar_t[]> utf8towchar(const std::string& in);
-#define strcasecmp _stricmp
-#define strncasecmp _strnicmp
+// #define strcasecmp _stricmp
+// #define strncasecmp _strnicmp
 #define localtime_r(a,b) localtime_s(b,a)
 #define strtok_r strtok_s
 #endif // _WIN32

        8)修改src/xaposix/safeunistd.h



# git diff src/xaposix/safeunistd.h
diff --git a/src/xaposix/safeunistd.h b/src/xaposix/safeunistd.h
index e0e67c2d..af7e4c3e 100644
--- a/src/xaposix/safeunistd.h
+++ b/src/xaposix/safeunistd.h
@@ -22,9 +22,9 @@
 #define XAPIAN_INCLUDED_SAFEUNISTD_H
 
 #ifndef _MSC_VER
-# include <unistd.h>
-#define sys_read ::read
-#define sys_write ::write
+#include <unistd.h>
+//#define sys_read ::read
+//#define sys_write ::write
 
 #else
 

3.3、编译

       recoll在1.37及之前使用GNU autotools编译系统,从1.38版本开始使用meson/ninja编译系统。

        1)meson setup

        meson setup --reconfigure -Dlibmagic=false -Dx11mon=false build

        或者修改src/meson_options.txt把recollq缺省值改为true,把libmagic和x11mon的缺省值改为false。

        2)ninja

        ninja -C build

4、输出成果物

        参考src/windows/mkinstdir.sh的内容,拷贝成果物和资源到输出目录。

        缺少的dll可通过ldd librecoll-39.dll,ldd recollindex.exe,ldd recollq.exe,ldd recoll.exe查找补齐。

5、总结

        本指南只编译输出recoll.exe、recollq.exe、recollindex.exe满足基本的索引创建和检索功能,复杂文件格式的解析,特别是python脚本的支持这块没有尝试,仅供学习试用。

        如果想使用全功能版本,可以支付一定的费用(5-20欧元)从原作者那边获取完整编译后的版本。Recoll on Windows

  • 全部评论(0)
最新发布的资讯信息
【系统环境|】如何在日期天数后快速加上第n天的英文后缀?(2025-11-13 22:32)
【系统环境|】法兰的基本知识(2025-11-13 22:32)
【系统环境|】「从零搭建」用 SpringBoot + 向量搜索打造智能短视频推荐系统!(2025-11-13 22:31)
【系统环境|】常用英语词语辨析105组(内容有点多,请收藏备用)(2025-11-13 22:31)
【系统环境|】英语高级词汇:asylum(2025-11-13 22:30)
【系统环境|】第1章 电气家装仪表的使用方法与技巧(2025-11-13 22:29)
【系统环境|】最快获得VC的方式#NBA2K(2025-11-13 22:29)
【系统环境|】用 VitePress 搭建电子书,绝了!(2025-11-13 22:28)
【系统环境|】时隔多年,VitePress 终于迎来了 v1.0 !(2025-11-13 22:28)
【系统环境|】每日 GitHub 探索|探索一系列热门开源项目,提升你的技能(2025-11-13 22:27)
手机二维码手机访问领取大礼包
返回顶部