Installing C/C++ GNU Compilers on Windows

Find Tips and tricks on how to better use the Zeus IDE. Feel free to post your own tips but please do not post bug reports, feature requests or questions here.
Post Reply
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Installing C/C++ GNU Compilers on Windows

Post by jussij »

There are many examples of how to install the GNU GCC and G++ compilers on Windows including many found on this forum.

The problem with most of these is they date very quickly, and any option that does not age with time will always a better option and it turns out the MSYS2 is just such an option.
  1. To start, go to MSYS2 the home page and download and install the software as per the instructions found here: https://www.msys2.org/
  2. Once installed, open the shell using the following batch file found in the installation folder, or alternatively use the MSYS2, Windows Start menu to open the shell:

    Code: Select all

    msys2_shell.cmd
  3. As per the details found on the earlier link, it is now very easy to install the GNU C compiler using a command like this:

    Code: Select all

    pacman -S mingw-w64-ucrt-x86_64-gcc
  4. To install the complete set of development tools, use the toolchain package described here: https://packages.msys2.org/groups/mingw ... -toolchain

    It can be installed using the following command:

    Code: Select all

    pacman -S mingw-w64-ucrt-x86_64-toolchain
  5. The non-ucrt version of this package is found here: https://packages.msys2.org/groups/mingw ... -toolchain

    It can be installed using the following command:

    Code: Select all

    pacman -S mingw-w64-x86_64-toolchain
    NOTE: The ucrt packages use the Universal CRT rather than the much older msvcrt.dll runtime.
  6. In addition, as these commands are installing MinGW compilers, by searching for these artifacts and adding those folder locations to the system PATH means these compilers can also be run from the Windows command prompt:

    Code: Select all

    gcc.exe

    Code: Select all

    g++.exe
  7. Finally, by using the MSYS2 command prompt you can use a suitable pacman command to upgrade these compilers as needed. Just refer to the MSYS2 site for more details.
Jussi
Post Reply