最新版Seafile在Windows10环境下的详细编译步骤(2025年3月)

最新版Seafile在Windows10环境下的详细编译步骤(2025年3月)

基本参考官网:

https://manual.seafile.com/12.0/develop/windows/

但,其内容不详细,且有一些缺失或错误。
本文根据实操验证,可成功。编译均为Release x64。


00、基本环境(带星号为建议版本,即如果更换版本可能会失败)

  • Git for Windows
  • Python 3
  • OpenSSL
  • Visual Studio 2019 Community *
  • Qt 6.5 *
  • QT VS Tools
  • vcpkg
  • Wix 3*
  • Paraffin

01、无需特别说明的
Git for Windows(略)
Python 3(略)
OpenSSL(略)


02、Visual Studio 2019 Community

https://pan.baidu.com/s/1ML-Yf2-r6cQKNp1avORFvA?pwd=frhu

除默认外,添加以下组件

[工作负荷]
使用C++的桌面开发
通用Windows平台开发
[单个组件]
MSVC v142
Windows 10 SDK (10.0.19041.0) (installed by default, not used)
Windows 10 SDK (10.0.18362.0)
[语言包]
英语
[安装位置]
D:\apps\VisualStudio2019
D:\apps\VisualStudioPkg
D:\apps\VisualStudioShared


03、Qt6.5

https://mirrors.ustc.edu.cn/qtproject/official_releases/online_installers/qt-online-installer-windows-x64-online.exe

现在Qt都是在线安装。安装参数:

1
qt-online-installer-windows-x64-online.exe --mirror https://mirrors.ustc.edu.cn/qtproject

[选择组件]
Qt 6.5
MSVC 2019 64-bit
Qt 5 Compatibility Module
Qt Positioning
Qt Serial Port
Qt WebChannel
Qt WebEngine
[安装位置]
D:\3rd\qt


04、QT VS Tools

https://download.qt.io/development_releases/vsaddin/3.3.1/qt-vsaddin-msvc2019-x86-3.3.1.vsix


05、vcpkg

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
bootstrap-vcpkg.bat
vcpkg integrate install
vcpkg install curl[core,openssl]:x64-windows
vcpkg install getopt:x64-windows
vcpkg install glib:x64-windows
vcpkg install jansson:x64-windows
vcpkg install libevent:x64-windows
vcpkg install libwebsockets:x64-windows
vcpkg install openssl:x64-windows
vcpkg install pthreads:x64-windows
vcpkg install sqlite3:x64-windows
vcpkg install zlib:x64-windows
vcpkg install argon2:x64-windows

设置环境变量

1
2
VCPKG_DEFAULT_POWERSHELL_PATH =
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

06、Wix和Paraffin

https://github.com/wixtoolset/wix3/releases/tag/wix3111rtm

可选择绿色免安装包,解压到D:\3rd\wix。之后下载:

https://github.com/Wintellect/Paraffin/releases

解压到Wix/bin目录,如果是绿色版没有bin,则直接解压到Wix目录。


07、安装并编译Breakpad

1
2
3
4
5
6
7
8
9
10
11
12
pip install setuptools
cd d:/3rd/
git clone --depth=1 https://github.com/chromium/gyp.git
cd gyp
python setup.py install
cd ..
git clone -b chrome_99 https://chromium.googlesource.com/breakpad/breakpad
cd breakpad\src
git clone https://github.com/google/googletest.git testing
cd ..\..
pip install six
gyp --no-circular-check breakpad\src\client\windows\breakpad_client.gyp

之所以拿chrome_99这个branch,是因为main没有breakpad_client.gyp这个文件。

打开breakpad_client.sln,配置VS项目属性:

常规 —> 语言标准:改为C++17;
C/C++ —> 代码生成 —> 运行库:改为多线程DLL(/MD)。

打开unittests下几个项目的属性:

配置属性 —> C/C++ —> 常规:
警告等级 —> 等级3(/WX3)

再次编译,可以忽略gtest项目的编译错误。


08、编译tools_windows和dump_syms工具

1
gyp --no-circular-check breakpad\src\tools\windows\tools_windows.gyp

打开tools_windows.sln,修改C++语言标准为C++17;设置C/C++代码生成的运行库为多线程DLL(/MD)(仅限ms_symbol_server_converter)。
编译tools_windows。会出现错误。打开pdb_source_line_writer.h文件,插入行:

1
#include <memory>

如果警告被视为错误无法编译,则把所有64位int警告的位置修改为——

1
static_cast<int>(xxx)

或者——

1
(int)xxx

编译dump_syms。


09、一些额外的文件
复制

D:\apps\VisualStudio2019\Common7\IDE\Remote Debugger\x64\msdia140.dll

D:\3rd\breakpad\src\tools\windows\Release

复制

Microsoft_VC142_CRT_x64.msm

D:\3rd\packagelib

注意:如果本机找不到Microsoft_VC142_CRT_x64.msm,就去网上下载一个。


10、从Github下载seafile源码:

https://github.com/orgs/haiwen/repositories

[解压位置]
D:\proj\pzbox-seafile

注意:活跃的几个项目(如seafile、seafile-client)很可能master默认分支是无法编译的,因此建议选择某个tag。


11、按顺序编译:

  • libsearpc
  • seafile
  • seafile-client/third_party/quazip
  • seafile-client
  • seafile-shell-ext

如遇glib.h等找不到错误,添加变量:VC++目录 –> 包含目录:

1
2
3
D:\3rd\vcpkg\packages\glib_x64-windows\lib\glib-2.0\include
D:\3rd\vcpkg\packages\glib_x64-windows\include\glib-2.0
D:\3rd\breakpad\src

VC++目录 –> 库目录:

1
D:\3rd\breakpad\src\client\windows\Release\lib

12、设置PATH环境变量、最后的准备工作
[PATH]

1
2
C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64
D:\apps\VisualStudio2019\Common7\IDE

生成pfx证书(用于打包)

1
2
3
openssl genrsa -out pz.key 2048
openssl req -new -x509 -key pz.key -out pz.csr -days 3650 -subj /CN=*.pzbox.cn
openssl pkcs12 -export -out pzbox.pfx -inkey pz.key -in pz.csr

修改seafile/scripts/build/build-msi-vs.py

1
2
3
4
5
6
CERTFILE = "D:/proj/pzbox-seafile/pzbox.pfx"
QT_DIR = "D:/3rd/qt/6.5.3/msvc2019_64"
WIX_BIN = "D:/3rd/wix"
OPENSSL_DIR = "D:/3rd/packagelib"
dump_syms_path = os.path.join(BUILDDIR, 'breakpad', 'src', 'tools', 'windows', 'Release', 'dump_syms.exe')
dump_syms_path = os.path.join('d:/3rd', 'breakpad', 'src', 'tools', 'windows', 'Release', 'dump_syms.exe')

13、打包

1
2
cd D:\proj\pzbox-seafile\seafile\scripts\build
python build-msi-vs.py 1.0

最后,关于Seafile其他项目编译同理。Seafile结构较复杂,需要耐心。另外源码不是每个分支都能成功编译,不行就换一个。

参考资料
https://manual.seafile.com/12.0/develop/windows/
https://chromium.googlesource.com/breakpad/breakpad

p.s. CSDN也有一堆文章,参考意义不大,故未纳入参考范围。