Windows – Install GCC in Git for Windows bash environment

git-bashmingwmsyswindows 7

I have Git for Windows installed on a Windows 7 machine (no, sadly I can't switch to W10 on this particular machine). This comes with a bash environment that uses MinGW-64 but only includes some binaries. I'd like to add more, such as GCC.

It seems like there should be someway of adding to the MinGW-64 binaries within the git bash instead of adding a whole other MSYS2/MinGW-64 install. However I'm not exactly clear on what is the best way to go about enabling this. I have tried installing win-builds in the bash install usr/ directory (seemed like the place all the other binaries were). It seems to run OK but it doesn't seem to add anything AFAICT, no executables, no folders, nada… except if I try to run the install again it complains that there are already files there… though they patently aren't.

Thus my question is this: can I use win-builds or some other binary to achieve my aim and if so, how?

Note: There are several questions about this around the net and SE, but most are quite old and so no longer relevant AFAICT due to changes in MSYS2, MinGW and Git for Windows.

screenshot showing win-builds complaining that non-existant folders exist

Best Answer

USE MINGW-W64

  1. Install mingw-w64 (Follow the "Sourceforge" link) and install it to the default Program Files based path.

  2. Select the latest "version" (for GCC), change "architecture" from i686 (32-bit) to x86_64 (64-bit), and change "threads" to win32.

  3. Add the bin folder to the beginning of your Git BASH (MINGW64) path:

     $ export PATH="c:/Program Files/mingw-w64/x86_64-8.1.0-win32-seh-rt_v6-rev0/mingw64/bin:$PATH"
    

    You'll, of course, need to adjust the above path to match the version of your of your particular install:

     $ export PATH="c:/Program Files/mingw-w64/<YOUR_ARCH_VERSION_REVISION_FOLDER>/mingw64/bin:$PATH"
    

Alternatively

You may be able to just install it directly into the same folder as Git: C:\Program Files\Git.

But I haven't tried this alternative approach and I wouldn't recommend it because it is likely to cause issues when updating and may confuse uninstallers, leaving remnants. (if the two installations don't interfere to begin with)

[ Edit: GNU Make is installed as mingw32-make.exe. You can make a copy of it, somewhere in your $PATH which you have permission to, and rename it to make. Git Bash seems to respect that it's executable, even without an extension, which is handy if you don't want it picked up outside of the MinGW environment (even though it may be in your PATH). ]