Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'g++' is not recognized as an internal or external command, operable program or batch file

Tags:

c++

#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]

like image 619
Rakesh Dagdi Avatar asked Jul 29 '16 06:07

Rakesh Dagdi


People also ask

How do I fix g ++ not recognized?

You need to set the environment PATH to include the directory of mingw's bin directory if you want o use gcc.exe or g++.exe in cmd . run 'path' or 'echo %PATH% in cmd.exe prompt. Check the path carefully.

Why G ++ is not recognized Vscode?

If you don't see the expected output or g++ or gdb is not a recognized command, make sure your PATH entry matches the Mingw-w64 binary location where the compilers are located. If the compilers do not exist at that PATH entry, make sure you followed the instructions on the MSYS2 website to install Mingw-w64.


2 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

like image 113
msc Avatar answered Oct 09 '22 01:10

msc


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 ----

  1. After downloading, install MinGW and wait for the “MinGW Installation Manager” to show up.
  2. When the “MinGW Installation Manager” shows up, click on mingw32-gcc-g++ then select “Mark for Installation”
  3. In the menu at the top left corner, click on “Installation > Apply Changes”
  4. 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

like image 45
Sodrul Amin Shaon Avatar answered Oct 09 '22 01:10

Sodrul Amin Shaon