vscode clang ++:没有这样的文件或目录:'main.cpp'

时间:2019-11-18 23:01:20

标签: c++ visual-studio-code clang++

好的,这真令人沮丧。

我只是试图在VSCode编辑器中使用clang ++来编译位于项目的“ main”模块中的非常简单的main.cpp程序。

项目层次结构如下: $ {workspaceFolder} /   cpp /     主要/       main.cpp

为简便起见,我故意省略了许多其他文件夹和文件。

这是我的task.json构建任务的终端输出:

> Executing task: clang++ -Wall -std=c++17 -stdlib=libc++ -o main.out main.cpp -I/Users/ajm/Projects/restaurant/cpp/main/ --debug <

clang: error: no such file or directory: 'main.cpp'
clang: error: no input files
The terminal process terminated with exit code: 1

main.cpp显然在我要包含在-I的文件夹中(请参见以下屏幕截图):clang

我在这里想念什么呢???我非常想将我的C ++ IDE切换到Visual Studio或Xcode,因为除了这个问题之外,VSCode的C ++自动完成功能还存在很多bug,而且速度非常慢。

请注意,我刚开始使用clang ++。我已经阅读了5-10条其他类似问题的SO帖子,但都没有帮助。在LLVM或Microsoft网站上的Clang快速入门指南中,我也没有发现任何有用的信息。

如果有人需要更多信息来回答问题,请告诉我。

有人,请帮忙!预先感谢。

编辑: 我想我还将包括我的task.json,c_cpp_properties.json和launch.json文件。

tasks.json:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Build with Clang",
      "type": "shell",
      "command": "clang++",
      "args": [
        "-Wall",
        "-std=c++17",
        "-stdlib=libc++",
        "-o",
        "main.out",
        "main.cpp",
        "-I${workspaceFolder}/cpp/main/",
        "--debug"
      ],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}

c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Mac",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/local/boost_1_71_0"
            ],
            "defines": [],
            "macFrameworkPath": [
                "/System/Library/Frameworks",
                "/Library/Frameworks"
            ],
            "compilerPath": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "${default}",
            "browse": {
                "path": []
            }
        }
    ],
    "version": 4
}

launch.json:

{
  // 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": "(lldb) Launch",
      "type": "cppdbg",
      "request": "launch",
      "program": "enter program name, for example ${workspaceFolder}/main.out",
      "args": [],
      "stopAtEntry": false,
      "cwd": "${workspaceFolder}",
      "environment": [],
      "externalConsole": false,
      "MIMode": "lldb",
      "logging": {
        "trace": true,
        "traceResponse": true,
        "engineLogging": true
      }
    }
  ]
}

0 个答案:

没有答案