drakebakincake
drakebakincake

Reputation: 101

Problem with Mingw even with setting paths

enter image description here

I've been trying to setup C++ on my laptop. I've installed Mingw and the packages. I have the bin path (C:\MinGW\bin) in Path location. I've tried both Path user and system but I still get g++ is not recognized in command prompt. In the terminal of Visual Studio Code, I run g++ --version, I get the correct response. But when running a program, it'll say g++ is not recognized.

CMD PATH C:\MinGW\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Windows\System32\MinGW\bin;C:\Users\drake\AppData\Local\Programs\Python\Python39\Scripts;C:\Users\drake\AppData\Local\Programs\Python\Python39;C:\Program Files\Java\jdk-12.0.1\bin;C:\Users\drake\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\drake\AppData\Local\Microsoft\WindowsApps;C:\Windows\system32;C:\Windows;C:\Windows\system32\Wbem;C:\Windows\system32\WindowsPowerShell\v1.0;C:\Windows\system32\OpenSSH;C:\MinGW\bin;

PowerShell C:\MinGW\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Windows\System32\MinGW\bin;C:\Users\drake\AppData\Local\Programs\Python\Python39\Scripts;C:\Users\drake\AppData\Local\Programs\Python\Python39;C:\Program Files\Java\jdk-12.0.1\bin;C:\Users\drake\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\drake\AppData\Local\Microsoft\WindowsApps;C:\Windows\system32;C:\Windows;C:\Windows\system32\Wbem;C:\Windows\system32\WindowsPowerShell\v1.0;C:\Windows\system32\OpenSSH;C:\MinGW\bin;

EDIT: gcc and g++ only work when I do gcc.exe --version or g++.exe --version. This causes problem with visual studio code because when trying to run the program, it's running with just gcc instead of gcc.exe.

Upvotes: 0

Views: 1303

Answers (3)

drakebakincake
drakebakincake

Reputation: 101

Turns out the problem was my PATHEXT the whole time. I must have enter a new pathext variable a while ago for some reason and it messed it all up.

Upvotes: -1

Suryansh Singh
Suryansh Singh

Reputation: 1173

I assume you are doing so to get g++ compiler. And in case you are unable to rectify the problem you can do following:

  1. First of all, install Windows Subsystem for LInux on Windows Features. Reboot.

  2. Install Ubuntu.

  3. Run bash and create a user account with a password.

  4. Make a “sudo apt update” to update the repo packages.

  5. Then you can do “sudo apt install gcc” and “sudo apt install g++”.

  6. Use Remote wsl on VS.

  7. Mnt your files on wsl

Upvotes: -1

Titoot
Titoot

Reputation: 120

there's a couple of things that can cause that

First, make sure that you installed MinGW probably as shown in this picture: 1

second, make sure that in C:\MinGW\bin gcc.exe and g++.exe are located and working probably (run them from the cmd in the same folder)

after that close the cmd if it's opened and try to type gcc or g++

and if it didn't work you can check the PATH by typing echo %PATH% and you C:\MinGW\bin separated by a semicolon

Upvotes: 0

Related Questions