i can't run c++ on vscode

114 Views Asked by At

So, i have followed this guide and watched this video i even check that (gcc,g++,gdb) --version command works but i still have an issue once i try to run my code:

#include <iostream>
using namespace std;
int main(){
    cout << "Hello World" << endl;
    return 0;
}

the issue:

Starting build...
cmd /c chcp 65001>nul && C:\msys64\ucrt64\bin\gcc.exe -fdiagnostics-color=always -g C:\Users\matLe\Documents\martin\programmation\premier_dossier\programme.cpp -o C:\Users\matLe\Documents\martin\programmation\premier_dossier\programme.exe
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\matLe\AppData\Local\Temp\ccGOz3M3.o: in function `main':
C:/Users/matLe/Documents/martin/programmation/premier_dossier/programme.cpp:4:(.text+0x22): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/matLe/Documents/martin/programmation/premier_dossier/programme.cpp:4:(.text+0x34): undefined reference to `std::ostream::operator<<(std::ostream& (*)(std::ostream&))'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\matLe\AppData\Local\Temp\ccGOz3M3.o:programme.cpp:(.rdata$.refptr._ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_[.refptr._ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_]+0x0): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\matLe\AppData\Local\Temp\ccGOz3M3.o:programme.cpp:(.rdata$.refptr._ZSt4cout[.refptr._ZSt4cout]+0x0): undefined reference to `std::cout'
collect2.exe: error: ld returned 1 exit status

my task.json file content:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: gcc.exe build active file",
            "command": "C:\\msys64\\ucrt64\\bin\\gcc.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "C:\\msys64\\ucrt64\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ]
}
0

There are 0 best solutions below