“无法在 Ubuntu WSL2 中打开源文件”iostream“”

"cannot open source file "iostream"" in Ubuntu WSL2

提问人:Shuto 提问时间:10/23/2023 最后编辑:Ulrich EckhardtShuto 更新时间:10/23/2023 访问量:54

问:

我正在尝试使用带有 WSL2 的 Ubuntu 运行 helloworld,但出现错误。 错误为“无法打开源文件”iostream”。

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
   vector<string> msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};

   for (const string& word : msg)
   {
      cout << word << " ";
   }
   cout << endl;
}

includepath如下

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/include/c++/12"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c17",
            "cppStandard": "gnu++17",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

我在 includePath 中添加了“/usr/include/c++/12”,波浪线在上面消失了。

C++ Ubuntu Windows-subsystem-for-Linux iostream

评论


答: 暂无答案