依赖:

1.cmake安装

  1.1下载 CMake:

    官网:https://cmake.org/download/

    选择 Windows 安装包(如 cmake-3.xx.x-windows-x86_64.msi)

  1.2安装时务必勾选:

    Add CMake to the system PATH for all users(或当前用户)

  1.3完成安装后重启终端。

  1.4验证

    cmake --version

2.mingw安装

  2.1下载 CMake:

    官网:WinLibs - GCC+MinGW-w64 compiler for Windows)  --建议去github下载

  2.2免安装:

    但是要设置环境变量

  2.3完成安装后重启终端。

  2.4验证

    g++ --version

  2.5参考

    最新!MinGW-w64的下载与安装(超详细!!!) - 知乎

 

注意点:

  符合的文件写完之后,需要如下方式生成可执行文件:

  cmake -S . -B build -G "MinGW Makefiles"    

  mingw32-make

  -G "MinGW Makefiles"
    -G: 指定 生成器(Generator),用于选择构建系统类型。
    "MinGW Makefiles": 明确要求生成 MinGW 兼容的 Makefile。
  作用:
    适用于 Windows 平台的 MinGW 或 MSYS2 环境。
    生成标准的 Makefile 文件,可通过 mingw32-make.exe 执行编译。
    确保 CMake 调用 MinGW 工具链(如 gcc.exe、g++.exe

    

  

实际工程代码:

https://files.cnblogs.com/files/effortscodepanda/xshell_windows.7z?t=1749393056&download=true

 

https://files.cnblogs.com/files/effortscodepanda/xshell_not_gtest.7z?t=1749527202&download=true