首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >错误:以退出代码-1终止的preLaunchTask构建,启动程序不存在。

错误:以退出代码-1终止的preLaunchTask构建,启动程序不存在。
EN

Stack Overflow用户
提问于 2022-07-31 18:58:39
回答 1查看 426关注 0票数 1

最近,我一直试图从CodeBlocks迁移到Visual代码,但后者给我带来了一些问题,特别是在使用类创建项目时,在本例中,当我试图运行它时,我得到了以下窗口:

preLaunchTask C/C++:G++..exe构建以退出代码-1结尾的活动文件

如果我单击“显示错误”,它会告诉我工作区中没有检测到问题。

然后单击“调试”之后,就会出现以下情况:

发射程序不存在

我已经有一段时间没有使用VScode了,但是我很确定启动程序是在第一次运行程序代码时创建的,对吗?

这是我的launch.json和task.json:

launch.json:

代码语言:javascript
运行
复制
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
    {
        "name": "(Windows) Launch",
        "type": "cppvsdbg",
        "request": "launch",
        "program": "${workspaceFolder}/myfile.exe",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": true
    },
    {
        "name": "(Windows) Attach",
        "type": "cppvsdbg",
        "request": "attach",
        "processId": "${command:pickProcess}"
    }
]

}

tasks.json:

代码语言:javascript
运行
复制
{
"version": "2.0.0",
"tasks": [
    {
        "label": "build myfile",
        "type": "shell",
        "command": "g++",
        "args": [
            "-std=c++14",
            "-g",
            "-o",
            "myfile.exe",
            "myfile.cpp"
        ],
        "group": "build"
    },
    {
        "type": "cppbuild",
        "label": "C/C++: g++.exe build active file",
        "command": "C:\\msys64\\mingw64\\bin\\g++.exe",
        "args": [
            "-fdiagnostics-color=always",
            "-g",
            "${file}",
            "-o",
            "${fileDirname}\\${fileBasenameNoExtension}.exe"
        ],
        "options": {
            "cwd": "${fileDirname}"
        },
        "problemMatcher": [
            "$gcc"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        },
        "detail": "Task generated by Debugger."
    }
]

}

对于类似的问题,我得到了所有的.json:https://stackoverflow.com/a/50658089/19009898,我以前有different.json,我猜这是默认的,但是这个更改似乎不会给之前没有类的其他代码带来任何麻烦,所以我想它是可以的。

会很感激你的帮助。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73186143

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档