【问题标题】:Clang build an executrion file in vscodeClang 在 vscode 中构建一个执行文件
【发布时间】:2022-11-04 17:22:52
【问题描述】:

我一直在搜索整个互联网,但找不到使用 clang 编译器构建我的 c++ 项目的解决方案。我对所有这些东西都很陌生,很抱歉造成误解。 我有默认的tasks.json 文件:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "clang++ build active file",
            "command": "C:/Program Files/LLVM/bin/clang++",
            "args": [
                "-std=c++17",
                "-stdlib=libc++",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
  }

我可以编译,这就是我编译的,3个文件:

我需要以某种方式创建可执行文件... 感谢帮助。

【问题讨论】:

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


    【解决方案1】:

    如果您使用read the documentation(用于MinGW,但对于Windows 的Clang 完全相同),您需要将.exe 后缀显式添加到您的输出文件中。

    因此,您的“可执行”文件是名为main 的文件,没有任何后缀或“扩展名”。

    您需要更改 tasks.json 文件以添加 .exe 后缀:

    "${fileDirname}/${fileBasenameNoExtension}.exe"
    # Note the suffix here -------------------^^^^
    

    【讨论】:

      猜你喜欢
      • 2013-08-17
      • 2019-12-21
      • 2021-01-26
      • 2011-03-02
      • 2011-12-17
      • 2010-11-29
      • 2020-03-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多