#include<iostream>
using namespace std;
int main()
{
cout<<"hi"<<endl;
return 0;
}
I am using Sublime text 3, and I am getting this error:
error- ‘g++’ is not recognized as an internal or external command, operable program or batch file. [Finished in 0.0s]
4 Answers
Try to set g++
to your system path.
You can refer to this: http://stephencoakley.com/2015/01/21/guide-setting-up-a-simple-c-development-environment-on-windows
For me, it’s easily fixed by two steps, as below:
-
Set the environment variable:
C:/MinGW/bin
-
Paste the following code in the “launch.json”:
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Compiler",
"type": "cppvsdbg",
"request": "launch",
"program": "C:/MinGW/bin",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true
},
]
}
I installed a C++ compiler (MinGw). It resolved my issue while running .cpp
from vsc editor. Follow this.
I faced the same problem while running the code from command line. And found out that I messed up with MinGW installation. So I reinstalled it,
Do this while installing MinGW —-
- After downloading, install MinGW and wait for the “MinGW Installation Manager” to show up.
- When the “MinGW Installation Manager” shows up, click on mingw32-gcc-g++ then select “Mark for Installation”
- In the menu at the top left corner, click on “Installation > Apply Changes”
- Wait and allow to install completely. Ensure you have a stable internet connection during this process.
when it is done, then edit the environment ‘Path’ Variable as stated in other answer.
In short I followed this