Visual studio code vscode tasks.json 2.0 g++;没有这样的文件或目录

Visual studio code vscode tasks.json 2.0 g++;没有这样的文件或目录,visual-studio-code,vscode-settings,Visual Studio Code,Vscode Settings,我是VSC的新手 我已经搜索了stackoverflow,但找不到与g++错误相关的问题/解决方案,没有这样的文件或目录。我在使用tasks.json 2.0版时遇到了这个问题 如果我在命令行上调用g++它就会编译并工作 My Subclass.cpp文件位于以下目录中: “/home/superben/ESP32VSC/codexamples/heritation/”,也在我的c_cpp_properties.json文件中 My c_cpp_properties.json: {

我是VSC的新手

我已经搜索了stackoverflow,但找不到与g++错误相关的问题/解决方案,没有这样的文件或目录。我在使用tasks.json 2.0版时遇到了这个问题

如果我在命令行上调用g++它就会编译并工作

My Subclass.cpp文件位于以下目录中:
“/home/superben/ESP32VSC/codexamples/heritation/”,也在我的c_cpp_properties.json文件中

My c_cpp_properties.json:

{
        "name": "Linux",
        "includePath": [
            "${workspaceFolder}",
            "/home/superben/ESP32VSC/CodeExamples/Inheritance",
            "/usr/include/c++/7",
            "/usr/include/x86_64-linux-gnu/c++/7",
            "/usr/include/c++/7/backward",
            "/usr/lib/llvm-6.0/lib/clang/6.0.1/include",
            "/usr/local/include",
            "/usr/include/x86_64-linux-gnu",
            "/usr/include"
        ],
        "defines": [],
        "intelliSenseMode": "clang-x64",
        "browse": {
            "path": [
                "${workspaceFolder}",
                "/home/superben/ESP32VSC/CodeExamples/Inheritance/",
                "/usr/include/c++/7",
                "/usr/include/x86_64-linux-gnu/c++/7",
                "/usr/include/c++/7/backward",
                "/usr/lib/llvm-6.0/lib/clang/6.0.1/include",
                "/usr/local/include",
                "/usr/include/x86_64-linux-gnu",
                "/usr/include"
            ],
            "limitSymbolsToIncludedHeaders": true,
            "databaseFilename": ""
        },
        "compilerPath": "/usr/bin/clang",
        "cStandard": "c11",
        "cppStandard": "c++17"
    },
My 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 subClass",
        "type": "shell",
        "command": "g++",
        "args": [
            "Subclass.cpp"
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        }
    }
]
}

VSC生成任务的输出错误:

> Executing task: g++ Subclass.cpp <

g++: error: Subclass.cpp: No such file or directory
g++: fatal error: no input files
compilation terminated.
The terminal process terminated with exit code: 1
执行任务:g++子类.cpp< g++:错误:Subclass.cpp:没有这样的文件或目录 g++:致命错误:没有输入文件 编译终止。 终端进程终止,退出代码为:1 很明显,在设置VSC以便它可以找到cpp文件方面,我缺少了一些简单的东西,但我不知道它是什么,我所回顾的问题都不能帮助解决。我没有Makefile,因为我认为这不是必需的,但也许这就是问题所在


谢谢你的洞察力

我无法执行任何可以更正生成的操作,因此我最终将代码从${workspaceFolder}/继承直接移动到${workspaceFolder},而不管我在c_cpp_properties.json中定义了什么“includePath”和“browse”“path”。我使用的是完全限定的目录结构,还是派生的${workspaceFolder}目录,这也无关紧要

如果代码不在${workspaceFolder}中,而是在该目录下的目录中(例如,${workspaceFolder}/Inhertance),则找不到该代码

因此,从我有限的知识和努力来看,似乎所有cpp代码(没有检查.h是否也受约束)都必须放在${workspaceFolder}中才能使“build task”正常工作


我在测试中没有使用Makefile,只是使用内置的“构建任务”。

BTW-我在Ubuntu 17.10上。另外,我在其他VSC项目上没有这个问题,因为它们都使用旧版本的tasks.json。本例中的版本是2.0.0,旧版本是“version”:“0.1.0”,所以我怀疑tasks.json就是问题所在。