You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Visual Studio 2019中编译Putty 0.78?遇CMake错误求助

PuTTY 0.78 Windows编译CMake错误解决指南

问题场景

编译Windows版PuTTY 0.78时,发现源码里没有Makefile.vc或Visual Studio项目文件。尝试在Visual Studio 2019中直接打开windows子目录,触发如下CMake错误:

Severity Code Description Project File Line Suppression State
Error CMake Error at C:\Users\user\Downloads\Compressed\putty-src\windows\CMakeLists.txt:3 (add_sources_from_current_dir):
Unknown CMake command "add_sources_from_current_dir". C:\Users\user\Downloads\Compressed\putty-src\windows\CMakeLists.txt 3

解决步骤

  • 从源码根目录启动CMake:PuTTY的自定义CMake函数(比如add_sources_from_current_dir)定义在根目录的CMake配置文件中,直接打开putty-src根目录(而非windows子目录)让VS自动加载完整的CMake配置,就能识别该函数。
  • 确认CMake版本达标:PuTTY 0.78要求CMake 3.14或更高版本,执行cmake --version检查版本,低于要求则更新CMake。
  • 命令行编译备选方案:若VS图形界面配置失败,在putty-src根目录执行以下命令生成VS工程文件:
    cmake -S . -B build -G "Visual Studio 16 2019" -A Win32
    
    (需要64位版本就把-A Win32改成-A x64)生成后打开build/PuTTY.sln即可正常编译,编译产物会输出到build/windows目录下。

内容的提问来源于stack exchange,提问作者dorita borita

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.08 03:10:39