Skip to content

编译SWRedirector

为了构建SWRedirector,需要这些依赖:

  • CMake >= 3.16
  • C 编译器 (Windows 下推荐 MSVC VS2022, Linux 下推荐 mingw-w64 交叉编译)

推荐构建 Release 版本以获得最佳性能

在 Windows 下使用 MSVC 构建

在 Visual Studio 2022 的 Developer PowerShellDeveloper Command Prompt 中运行:

powershell
cmake -B build -S . -G "Visual Studio 17 2022" -A x64 \
      -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release

在 Linux 下使用 MinGW 交叉编译

确保已安装 x86_64-w64-mingw32-gcc 等交叉编译工具链。

shell
cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=./toolchain-mingw64.cmake \
      -DCMAKE_BUILD_TYPE=Release
cmake --build build

编译选项

你可以通过 cmake -D<OPTION>=<VALUE> 的方式传递参数:

  • -DUSE_DOH=ON: 启用 DNS over HTTPS