你如何设置 Clang 和 VS Code 来为 Windows 上的 Linux 编译

问题描述

我正在尝试设置一个认的 VS Code 项目,我可以为 C++ 项目复制和粘贴该项目。我已经安装了 Clang/LLVM 并且我在 tasks.json 中得到了一个可以为 Windows 构建的任务。我的问题是,当我尝试通过将 --target 变量更改为同一物理平台上的 Linux 目标来创建为 Linux 构建的任务时,我最终收到了无法找到 <iostream>错误。我不确定这是我出错的 tasks.json 还是我不知道的叮当问题。 (我对跨平台很陌生)

我的tasks.json

{
    "version": "2.0.0","tasks": [
      {
        "type": "shell","label": "Build Clang for Windows x64 (Debug)","command": "clang++","args": [
          "-std=c++17","--target=x86_64-pc-win32-gnu","-g","${workspaceFolder}/Src/*.cpp","-o","${workspaceFolder}/Bin/Debug/Windows/x64/out.exe"
        ],"options": {
          "cwd": "${workspaceFolder}"
        },"problemmatcher": [
          "$gcc"
        ],"group": {
          "kind": "build","isDefault": true
        }
      },{
        "type": "shell","label": "Build Clang for Linux x64 (Debug)","-stdlib=libc++","--target=x86_64-pc-linux-gnu","${workspaceFolder}/Bin/Debug/Linux/x64/out"
        ],"problemmatcher": [
          "$gcc"
        ]
      }
    ]
  }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)