【问题标题】:why tasks.json: file format not recognized为什么tasks.json:文件格式无法识别
【发布时间】:2020-10-13 22:41:28
【问题描述】:

我在 ubuntu16 上运行 VScode,并测试 helloworld.cpp。 起初,我浏览了所有内容,然后尝试编辑 tasks.json。 我得到了错误。好的,我通过回滚取消了所有更改,它再次显示错误。 我删除 helloworld 文件夹并再次尝试 helloworld。 在终端 > 配置默认构建任务并构建之后,错误再次显示。 怎么了?它是从 vscode 获得的。

错误信息:

执行任务:/usr/bin/g++ -g /home/liwenz/helloworld/.vscode/tasks.json -o /home/liwenz/helloworld/.vscode/tasks

/usr/bin/ld:/home/liwenz/helloworld/.vscode/tasks.json:文件格式无法识别;视为链接描述文件 /usr/bin/ld:/home/liwenz/helloworld/.vscode/tasks.json:1:语法错误 collect2:错误:ld 返回 1 个退出状态 终端进程以退出代码终止:1

tasks.json

{
"version": "2.0.0",
"tasks": [
    {
        "type": "shell",
        "label": "C/C++: g++ build active file",
        "command": "/usr/bin/g++",
        "args": [
            "-g",
            "${file}",
            "-o",
            "${fileDirname}/${fileBasenameNoExtension}"
        ],
        "options": {
            "cwd": "${workspaceFolder}"
        },
        "problemMatcher": [
            "$gcc"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        }
    }
]

}

helloworld 链接是https://code.visualstudio.com/docs/cpp/config-linux

【问题讨论】:

    标签: visual-studio-code compiler-errors format vscode-tasks


    【解决方案1】:

    您必须从 tasks.json 文件切换到要编译或调试的实际代码。

    【讨论】:

      【解决方案2】:

      在构建时,我会打开 tasks.json。所以 ${File}=tasks.json 我应该打开 helloworld.cpp,然后 ${File}=helloword.cpp,然后构建即可。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2022-11-14
        • 2018-02-15
        • 1970-01-01
        • 1970-01-01
        • 2021-01-13
        • 2013-06-12
        • 1970-01-01
        • 2011-05-25
        相关资源
        最近更新 更多