altasgeorge
altasgeorge

Reputation: 1

Msys2/MinGW-w64: Can't locate iostream - error: "cannot open source file iostream"

I'm new to coding, and our teacher advised us to use Virtual Studio Code as our text editor, and also to follow YouTube tutorials on how to install Msys2 and the MinGW-w64 toolchain to use as a compiler for our C++.

Well, I followed the tutorial. Downloading the installer in the Msys2 site, putting commands like pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain and pacman -S mingw-w64-ucrt-x86_64-gcc. Following through the window terminal. Editing the system path in the environment variables.

Then, when I tried to input #include <iostream> it appears with a squiggly red line which states my current problem, "cannot open source file iostream".

Then I looked for a way to locate the header file on this website. Like, adjusting configurations and adding the path of my compiler (C:/msys64/ucrt64/include) into the include path. Typing the command gcc -v -E -x c++ - in the terminal and then adding it also to the Include Path. But it still does not function; the red squiggle line stays.

I'm new and eager to learn C++, but can't pass this stage.

testing.cpp:

#include<iostream>

c_cpp_properties.json:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${default}",
                "C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../include/c++/14.1.0/x86_64-w64-mingw32",
                "C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../include/c++/14.1.0/backward",
                "C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/include",
                "C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/../../../../include",
                "C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/14.1.0/include-fixed",
                "C:/msys64/ucrt64/include"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "cStandard": "c17",
            "cppStandard": "gnu++17",
            "compilerPath": "C:/msys64/ucrt64/bin/gcc.exe"
        }
    ],
    "version": 4
}

Upvotes: 0

Views: 91

Answers (0)

Related Questions