编译SWRedirector
为了构建SWRedirector,需要这些依赖:
CMake >= 3.16C 编译器(Windows 下推荐MSVC VS2022, Linux 下推荐mingw-w64交叉编译)
推荐构建 Release 版本以获得最佳性能
在 Windows 下使用 MSVC 构建
在 Visual Studio 2022 的 Developer PowerShell 或 Developer 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