首页 新闻 赞助 找找看

VScode: launch: program ...... dose not exist

0
悬赏园豆:20 [已解决问题] 解决于 2023-01-03 08:03

第一次用VScode,没啥经验,运行时出现这种情况是什么原因,网上找了很多方法都没用。

s

launch.json:

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

tasks.json:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "command": "msbuild",
            "args": [
                // Ask msbuild to generate full paths for file names.
                "/property:GenerateFullPaths=true",
                "/t:build",
                // Do not generate summary otherwise it leads to duplicate errors in Problems panel
                "/consoleloggerparameters:NoSummary"
            ],
            "group": "build",
            "presentation": {
                // Reveal the output only if unrecognized errors occur.
                "reveal": "silent"
            },
            // Use the standard MS compiler pattern to detect errors, warnings and infos
            "problemMatcher": "$msCompile"
        }
    ]
}

c_cpp_properties.json

{
  "configurations": [
    {
      "name": "windows-gcc-x64",
      "includePath": [
        "${workspaceFolder}/**"
      ],
      "compilerPath": "E:/mingw64/bin/gcc.exe",
      "cStandard": "${default}",
      "cppStandard": "${default}",
      "intelliSenseMode": "windows-gcc-x64",
      "compilerArgs": [
        ""
      ]
    }
  ],
  "version": 4
}

settings.json

{
  "C_Cpp_Runner.cCompilerPath": "gcc",
  "C_Cpp_Runner.cppCompilerPath": "g++",
  "C_Cpp_Runner.debuggerPath": "gdb",
  "C_Cpp_Runner.cStandard": "",
  "C_Cpp_Runner.cppStandard": "",
  "C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvarsall.bat",
  "C_Cpp_Runner.useMsvc": false,
  "C_Cpp_Runner.warnings": [
    "-Wall",
    "-Wextra",
    "-Wpedantic",
    "-Wshadow",
    "-Wformat=2",
    "-Wconversion",
    "-Wnull-dereference",
    "-Wsign-conversion"
  ],
  "C_Cpp_Runner.enableWarnings": true,
  "C_Cpp_Runner.warningsAsError": false,
  "C_Cpp_Runner.compilerArgs": [],
  "C_Cpp_Runner.linkerArgs": [],
  "C_Cpp_Runner.includePaths": [],
  "C_Cpp_Runner.includeSearch": [
    "*",
    "**/*"
  ],
  "C_Cpp_Runner.excludeSearch": [
    "**/build",
    "**/build/**",
    "**/.*",
    "**/.*/**",
    "**/.vscode",
    "**/.vscode/**"
  ]
}
全角的!与半角的!的主页 全角的!与半角的! | 初学一级 | 园豆:138
提问于:2022-12-31 14:40
< >
分享
最佳答案
1

launch.json中"program"改为"${workspaceFolder}/${fileBasenameNoExtension}.exe"就OK了

收获园豆:15
瓶瓶罐罐 | 菜鸟二级 |园豆:201 | 2023-01-01 19:41

还是不行,能不能让我看一下你配置的

全角的!与半角的! | 园豆:138 (初学一级) | 2023-01-02 11:48

@蝠气满满:
我用的是GCC,不知道你用的是不是
task.json

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe 生成活动文件",
            "command": "E:/mingw64/bin/g++.exe", //这里改成你自己的G++的路径
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
                "-O2",
                "-Wall",
                "-std=c++14"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "调试器生成的任务。"
        }
    ],
    "version": "2.0.0"
}

launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) 启动",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "E:/mingw64/bin/gdb.exe", //这里改成你自己的GDB的路径
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description":  "将反汇编风格设置为 Intel",
                    "text": "-gdb-set disassembly-flavor intel",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

c_cpp_properties.json都是默认选项,可以删掉
建议卸载C/C++ Runner插件,换成Code Runner,然后把settings.json中C_Cpp_Runner打头的全部删掉(没有忽略)
另外,插件和VSCode自带的调试工具是不同的,上面的两个配置文件是针对自带的。右上角那个运行▶️按钮右边应该有一个小箭头,点开,"调试(运行)C/C++文件"是自带的

瓶瓶罐罐 | 园豆:201 (菜鸟二级) | 2023-01-05 13:39

经过实验,C/C++ Runner插件生成的配置文件有一定局限性,包括文件名、目录等等,建议卸载,自带的功能已经足够了

瓶瓶罐罐 | 园豆:201 (菜鸟二级) | 2023-01-05 13:44

@瓶瓶罐罐: 感谢,现在好了。

全角的!与半角的! | 园豆:138 (初学一级) | 2023-01-05 15:27
其他回答(1)
1

建议参考 10分钟搞定Visual Studio Code配置C/C++开发环境 中的 launch.json 配置试试

收获园豆:5
dudu | 园豆:31075 (高人七级) | 2022-12-31 14:55

还是没用,我按照上面改过后运行时弹出下面这个窗口,选择仍要调试后还是出现问题上的窗口

d

支持(0) 反对(0) 全角的!与半角的! | 园豆:138 (初学一级) | 2022-12-31 19:44
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册