1. Download and Install MSYS2

First, download MSYS2 from the following direct link:

Download MSYS2

Run the installer and follow the installation instructions.

2. Update the Package Database and Base Packages

Open the MSYS2 terminal (the default terminal that comes with MSYS2). Run the following command to update the package database and base packages:

pacman -Syu

3. Update the Rest of the Base Packages

After the initial update, run the following command to update the rest of the base packages:

pacman -Su

4. Install GCC and G++ for C and C++

Now, open the MSYS2 MinGW terminal (the blue one). Use the following commands based on your system's architecture:

For 64-bit System:

pacman -S mingw-w64-x86_64-gcc

For 32-bit System:

pacman -S mingw-w64-i686-gcc

5. Install the Debugger (GDB) for C and C++

Similarly, to install the GDB debugger, use the following commands:

For 64-bit System:

pacman -S mingw-w64-x86_64-gdb