跳到主要内容

Windows

在 Windows 上,Goose 在构建期与运行期都依赖 Microsoft Visual C++ Redistributable。 注意与类 UNIX 系统不同,Windows 构建流程会直接调用 CMake。

Visual Studio

在 Windows 上构建 Goose,推荐使用 Visual Studio 编译器。 可参考 CI workflow 中的步骤:

python scripts/windows_ci.py
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_GENERATOR_PLATFORM=x64 \
-DENABLE_EXTENSION_AUTOLOADING=1 \
-DENABLE_EXTENSION_AUTOINSTALL=1 \
-DGOOSE_EXTENSION_CONFIGS="${GITHUB_WORKSPACE}/.github/config/bundled_extensions.cmake" \
-DDISABLE_UNITY=1 \
-DOVERRIDE_GIT_DESCRIBE="$OVERRIDE_GIT_DESCRIBE"
cmake --build . --config Release --parallel

MSYS2 与 MinGW64

在 Windows 上也可使用 MSYS2MinGW64 构建 Goose。 但该方式仅出于兼容性原因保留,建议仅在无法使用 Visual Studio 构建时采用。 使用 MinGW64 构建前,请通过 Pacman 安装依赖。 当提示 Enter a selection (default=all) 时,直接按 Enter 选择默认项。

pacman -Syu git mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja
git clone https://github.com/kumose/goose
cd goose
cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DBUILD_EXTENSIONS="icu;parquet;json"
cmake --build . --config Release

构建成功后,可在仓库目录中找到 goose.exe

./goose.exe

构建 Go 客户端

在 Windows 上构建时可能出现如下错误:

go build
collect2.exe: error: ld returned 5 exit status

GitHub 用户 vdmitriyev 分享了在 Windows 上构建 Goose Go 客户端的做法:

  1. libgoose-windows-amd64.zip 取出四个文件(.dll.lib.hpp.h)。

  2. 将它们放到例如 C:\goose-go\libs\

  3. goose-go 项目安装依赖。

  4. 按如下方式构建你的项目:

    set PATH=C:\goose-go\libs\;%PATH%
    set CGO_CFLAGS=-IC:\goose-go\libs\
    set CGO_LDFLAGS=-LC:\goose-go\libs\ -goose
    go build