
Optional: set this new compiler as the default. Everything else should have flat names ( gcc.exe, g++.exe, etc). Below this, change the names of all the options under Program Files to remove the mingw32- prefix, except for Make program which must remain mingw32-make.exe. Assuming default install location and a 64-bit toolchain, this should be C:\msys64\mingw64. Set the Compiler's installation directory to wherever you installed msys2 to + either mingw64 for a 64-bit toolchain or mingw32 for a 32-bit toolchain. On the compiler screen, there is a tab named Toolchain executables, click it. It will prompt you to update the toolchain executables. Give the new compiler profile a descriptive name (I went with MSYS2 mingw-w64-x86_64 G++. Under that setting there should be a button to copy it. It should be defaulted to the GNU GCC Compiler.
In the menu bar, click Settings->Compiler. If this is your first run, it will ask you about file associations and preferences and such. If you want the 32-bit toolchain you'd use pacman -Syu mingw-w64-i686-toolchain. install a mingw-w64 toolchain pacman -Syu mingw-w64-x86_64-toolchain, it will again prompt you with a choice of packages, you want them all so just hit enter. Last time I checked this, pacman was number 39 on the list, so you'd put in 1-38,40-56 for what to install (adjust for whatever $currentdate offers you, it may not always be 39). You want to skip pacman itself, otherwise it will have the same two-part update thing. install the base-devel package group $ pacman -Syu base-devel it will prompt you with a list of packages in the group. finish the msys2 update $ pacman -Syu this time the list will be much larger. update msys2 (two part process because windows can't easily swap a file in use out) $ pacman -Syu it will update a smallish subset of available packages and ask you to close the window. Take note of wherever you do install it, we'll need it later. Install msys2 (default install location is fine, C:\msys64 for 64 bit and I think C:\msys32 for 32 bit we'll assume 64 bit for the rest of this guide).
Use the installer with mingw already installed, we'll be copying some stuff from the default toolchain later. The basic gist is you'd want to install msys2 normally, as well as codeblocks, then use the codeblocks settings to set your compiler to use msys2's mingw-w64 compiler. Former msys2 & arch linux user here, currently enrolled in college where the class uses codeblocks as the standard metric for whether a program works or not, and I think I can help you here.