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

VS Code调试提示program文件不存在,常规方法尝试后仍未解决

VS Code C++调试报错:program不存在的解决方法

近期刚安装VS Code,调试C程序时反复报错:launch: program 'c:\Windows\System32\projects\helloworld\build\Debug\outDebug' does not exist,但程序能正常运行。已按官方C配置教程完成操作,卸载重装VS Code和编译器后问题仍未解决,提供的launch.json配置如下:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "C/C++ Runner: Debug Session",
      "type": "cppdbg",
      "request": "launch",
      "args": [],
      "stopAtEntry": false,
      "externalConsole": true,
      "cwd": "c:/Windows/System32/projects/helloworld",
      "program": "c:/Windows/System32/projects/helloworld/build/Debug/outDebug",
      "MIMode": "gdb",
      "miDebuggerPath": "gdb",
      "setupCommands": [
        {
          "description": "Enable pretty-printing for gdb",
          "text": "-enable-pretty-printing",
          "ignoreFailures": true
        }
      ]
    }
  ]
}

问题排查与解决步骤

  • 修正可执行文件路径后缀
    Windows下可执行文件必须带.exe后缀,你的program配置里缺少这个后缀,导致VS Code找不到对应文件。修改为:

    "program": "c:/Windows/System32/projects/helloworld/build/Debug/outDebug.exe"
    

    更推荐使用变量自动匹配项目路径,避免手动写错:

    "program": "${workspaceFolder}/build/Debug/outDebug.exe"
    
  • 确认可执行文件实际生成位置
    手动打开项目的build/Debug目录,确认编译后的可执行文件名和路径是否与配置一致。如果文件名不是outDebug.exe(比如是项目名helloworld.exe),要同步修改program字段的文件名。

  • 完善gdb路径配置
    miDebuggerPath直接写gdb可能因环境变量配置问题导致无法调用,建议填写gdb的完整路径(根据你的MSYS2安装路径调整),例如:

    "miDebuggerPath": "C:/msys64/mingw64/bin/gdb.exe"
    
  • 同步tasks.json与launch.json路径
    检查编译任务配置文件tasks.json中的输出路径,确保生成的可执行文件路径和launch.json里program指向的路径完全一致,避免编译和调试路径不匹配。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.12 14:32:45