0

I am trying to run C++ code on my OS (Windows 10). I installed MSYS2 and followed its instructions (using pacman to install gcc). The problem is after this step, when i type gcc --version i still get "gcc: command not found".

I added "C:\msys64\mingw32\bin" to my user variable's Path and ran the command again and i still get the same error. I am totaly confused here. Does anyone have any suggestion?

Thanks

eh329
  • 94
  • 10
  • Try logout/login, then it should work. – Jabberwocky Apr 17 '23 at 15:19
  • @Jabberwocky Yes, that is what i meant. What should i log out from? My account? – eh329 Apr 17 '23 at 15:20
  • 1
    A simple reboot can help with any environment variables that are only set when logging in. – tadman Apr 17 '23 at 15:26
  • @eh329 yes, logout from your Windows account. Reboot will work as well, but that's overkill. – Jabberwocky Apr 17 '23 at 15:27
  • @tadman Done that, does not work. – eh329 Apr 17 '23 at 15:35
  • @Jabberwocky Tried both. They do not work. – eh329 Apr 17 '23 at 15:35
  • 2
    You'll need to track down where `gcc.exe` is. Remember you can use [Visual Studio](https://visualstudio.microsoft.com) which has an integrated compiler. – tadman Apr 17 '23 at 15:42
  • 3
    If you still get that error after: ***I added "C:\msys64\mingw32\bin" to my user variable's Path and ran the command again and i still get the same error.*** Then for some reason either you did not install MinGW using msys2 or it failed or your `PATH` setting was wrong or is not applied to whatever command prompt you are typing in. You will have to 1. Look for `gcc.exe` and verify that it is located where you told your OS to look. 2. Check the `PATH` environment variable in the shell that you are using to see if the `PATH` you typed is actually being used. – drescherjm Apr 17 '23 at 15:48
  • 1
    [msys2 + gcc installation instructions that you have to work at to get wrong](https://stackoverflow.com/a/30071634/4581301) And a tactical note: Adding the compiler to the path will become a problem in the future if you find yourself having to use multiple gcc compilers. – user4581301 Apr 17 '23 at 16:53

1 Answers1

0

I suppose, for gcc on Windows you need download from sourceforge.net and run mingw-get-setup.exe

VolAnd
  • 6,367
  • 3
  • 25
  • 43
  • 3
    I would recommend against the sourceforge downloads. The MinGW version on sourceforge.net is usually very old. If you instead use msys2 you get the current MinGW with gcc-12.2 and also it contains a very good package management tool `pacman` and several thousand open source libraries that you can easily install using a 1 line install command. – drescherjm Apr 17 '23 at 15:50
  • @drescherjm Oddly enough, this is the only recommendation that worked. – eh329 Apr 17 '23 at 15:55
  • 2
    I still recommend you checking and understanding why the path of the executable was not found. Using a 6 to 10 year old version of g++ will limit what projects you can build. – drescherjm Apr 17 '23 at 16:00
  • 2
    @eh329 You will find that in the wonderful world of just about everything a lot of bad ideas sort of work. – user4581301 Apr 17 '23 at 16:48