Whenever I try to run C++ on Visual Studio code it outputs 'g++' is not recognized as an internal or external command, operable program or batch file. I've tried resetting my computer many times. I also got MinGW for the C++ complier. I've tried looking for solution's on the web and on here but could not find any.
Asked
Active
Viewed 6,553 times
0
-
Your bug is probably in your .json files. This should help you set them up: [https://code.visualstudio.com/docs/cpp/config-mingw](https://code.visualstudio.com/docs/cpp/config-mingw) – drescherjm May 26 '20 at 01:32
-
***Can anyone help with this?*** You have to show your configuration. It's difficult to help when you show very little. – drescherjm May 26 '20 at 02:16
-
***it outputs 'g++' is not recognized as an internal or external command*** That means that g++ is not installed where you told Visual Studio Code it was installed. Depending on your .json files you may be able to set the full path or it expects g++ to be in one of the folders of your windows PATH environment variable. – drescherjm May 26 '20 at 02:17
-
`tasks.json` contains the settings for how to build using g++. This is explained in the first link. – drescherjm May 26 '20 at 02:20
-
ok thanks this helped a lot I did some more research and your helped did it – Mreggsoup May 26 '20 at 02:29
-
2Exact duplicate: ['g++' is not recognized as an internal or external command, operable program or batch file](https://stackoverflow.com/questions/38652211/g-is-not-recognized-as-an-internal-or-external-command-operable-program-or). Please always search for error messages here - there are about 500 for this one. – halfer May 29 '20 at 21:25
1 Answers
2
If set up properly, VSCode will usually create available profiles for you. The following content is based on Windows 10, and it's simpler on other platforms.
- Install
MinGW
orMinGW-w64
. Make sure thebin
folder is inPATH
- In VSCode Folder/Workspace, delete or backup all profiles in
.vscode
. If.vscode
is not existing, create a empty.vscode
. - Open a example file such as
hello.c
, run it and follow the guides:C++(GDB/LLDB)
>>>gcc.exe...
.
If all goes well, VSCode will cerate lauch.json
and tasks.json
correctly. Then you can run or debug your c/cpp file now.

alexzshl
- 902
- 6
- 6