简体   繁体   中英

"g++" is not recognized as an internal or external command, MinGW

On my computer I have Windows 7 x86. I installed MinGW, I wrote the path but when I go in cmd.exe and write g++ -v it says:

"g++" is not recognized as an internal or external command.

But when I write the make -v command it recognizes it. I need this for school, I work in Eclipse, I even installed the latest java(I saw it must be installed).

You have to modify environment variables. Do the following:

  • From the desktop, right-click Computer and click Properties.
  • From the Computer Properties window, click Change Settings
  • In the System Properties window which opens up, click on the Advanced tab.
  • In the Advanced section, click the Environment Variables button.
  • Finally, in the Environment Variables window (as shown below), highlight the Path variable in the Systems Variable section and click the Edit button. Add or modify the path lines with the paths you wish the computer to access. Each different directory is separated with a semicolon as shown below.

    C:\\Program Files;C:\\Winnt;C:\\Winnt\\System32

Additionally you may refer to this link

Seeing that the make command works fine, I think you forgot to mark the mingw-gcc-g++ package in the MinGW Installation Manager.

Run the MinGW Installation Manager again and mark mingw-gcc-g++ for installation and press Apply Changes

I had the same problem in Sublime..

Right click on my computer
Advanced system settings
Environment variables
in system variables, change path to location of '...\MinGW\bin'

Example: D:\\work\\sublime\\MinGW\\bin

  1. Just go to the search bar a situated at bottom left of your task bar
  2. Search for environmental variables, after you click on the "Edit the system environmental variables"
  3. Click on Environmental variables
  4. Select Path(double click), Add new path
  5. Paste your Mingw-bin path, something like-"C:\MinGW\bin"
  6. Restart your computer
  7. Your gcc/gcc+ should be working fine now:)

How to Get the G++ Complier working Step by Step

--

If you dont have MINSYS you can download from here

in the Down load the installer section

https://www.msys2.org/

--

Then download MinGW

https://sourceforge.net/projects/mingw/

and install ALL packages

--

Now add both Minsys and MinGW you your C: folder

--

Then Open Minsys there should be a mingw 32 folder and a mingw 64 folder

Delete all files in both those folders

Then go to MinGW,

Take everything inside the mingw32 folder and paste it inside of the minsys mingw32 folder

Then Take everything inside the mingw64 folder and paste it inside of the minsys mingw64 folder

--

Now your minsys is ready to go.

--

Now you can update your PATHS so your computer can find and use it

--

Go to Settings > system about >> Advanced System Settings >> Enviroment Variables >> Click Path in top "User Variables for ***" Section (This will set theses PATHS only for this Computer User) >> Then click on the ADD button and paste C:\msys64\mingw64\bin

--

Important Note: After you entered in your PATHS in the Enviroment variables you should click TWO ok buttons, to Activate the edits.

So Click ok.

When that pop up closes that you entered in your path make sure to click OK AGAIN on the Original Enviroment Variables page, so that you finally set your new changes.

If you do not do this your changes will not be actually saved.

then you can open CMD ( if you already have it open make sure to close it first and then open it again fresh)

Then Type

gcc --version

Then

g++ --version

Then

gdb --version

if they all say there is a version installed you are good to go!

--

This fixed it for me, You can do it!

--

Additional link Help

https://code.visualstudio.com/docs/cpp/config-mingw#:~:text=If%20you%20don't%20see,website%20to%20install%20Mingw%2Dw64 .

Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM