I have very recently installed VS code and am an absolute newbie. I first had a different problem because I installed the wrong type of MinGW-W64, which I have now uninstalled, then it seemed to fix the problem, until I tried to build the code. A photo of what going to terminal > run build task shows me is shown in this photo. Terminal>Run Build Task
Extra details: I am using 3 c++ addons, C/C++ version 1.4.0, C/C++ Extension Pack version 1.0.0 and C++ Intellisense version 0.2.2. My code is an extremely simple and correct:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World" << endl;
}
My goal: I'm hoping to be able to run this code as intended in https://code.visualstudio.com/docs/languages/cpp (the tutorial I followed)
To show clarification on error messages, see this photo: error messages
By looking at the error message, you are currently executing the program in C:\Users\{username}
directory however your source code file helloworld.cpp
is present in C:\Users\{username}\OneDrive\Desktop
folder.
use cd "C:\Users\{username}\OneDrive\Desktop"
in your terminal to navigate to the folder and then run the g++ helloworld.cpp -o helloworld
command. After that run .\helloworld
to run your program.
Note that if you using VS code to build your program as mentioned here, then you only have to execute the .\helloworld
command to run it.