Ringo_00
Ringo_00

Reputation: 57

g++ not detected in either cmd and vs code

Using windows 10 and trying to set vs code, I installed MinGW with the package mingw32-gcc-g++-bin; modified the windows path adding the line ";C:\MinGW\bin" and mi json file looks as follow:

{
            "name": "Win32",
            "includePath": [
                "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/include/*",
                "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/um",
                "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/ucrt",
                "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/shared",
                "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/winrt",
                "C:/MinGW/bin",
                "${workspaceRoot}",
                "${workspaceFolder}"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE"
            ],
            "compilerPath": "C:/MinGW/bin/g++",
            "intelliSenseMode": "msvc-x64",
            "browse": {
                "path": [
                    "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.11.25503/include/*",
                    "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/um",
                    "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/ucrt",
                    "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/shared",
                    "C:/Program Files (x86)/Windows Kits/10/Include/10.0.16299.0/winrt",
                    "C:/MinGW/bin",
                    "${workspaceRoot}",
                    "${workspaceFolder}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        }

I also tried calling g++ from cmd terminal but it fails nonetheless with "g++ is not recognized as an internal or external command..."

Upvotes: 1

Views: 3956

Answers (1)

Mikael H
Mikael H

Reputation: 1383

"g++ is not recognized as an internal or external command" means g++ cannot be found in PATH. Either the program was not installed correctly, or the PATH is not correctly set.

First check that g++ really is in PATH. Open a new terminal and write g++. If the error message is there, do

cd C:\MinGW\bin 
g++

. Windows does not only search in the PATH-variable, but also in the current directory. if the error message is still there, then g++ is not to be found there (can you see g++.exe in file explorer for the current path?). If the error message is gone and the application starts (but is complaining about missing arguments) path is not correctly set. Check path variable by doing

echo %PATH%

and verify that C:\MinGW\bin is missing. Add it locally firstly, and try to execute g++ from another directory: set PATH=%PATH%;C:\MinGW\bin cd .. g++ we are now calling g++ from the parent folder, which should now work, as g++ is now successfully found in PATH. Note however that this is a local PATH and it will only be found for the current command prompt.

Add g++ to path either for user or globally: https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/

After adding the variable as in the link, restart the terminal and try executing g++ again, but this time successfully. Restart Visual Studio Code to reload path variables and the program should be able to find g++ as well.

Upvotes: 1

Related Questions