Get to Know MSys2

Microsoft announced their Linux sub-system project named WSL, it’s design to run GUN tool chains under windows.

But there is a problem: build tools in WSL (no matter 1 or 2) is unable to build Windows binary file without cross-compiling. Sometimes building Linux binary files is useful, but sometimes not.

That’s why MSys2 was introduced.

MSYS2 isn’t “one tool to rule them all” but tries to focus on what it’s good at. It provides a native build environment, based on open-source software, and makes you feel right at home when you are already comfortable with Linux. There are good reasons to use multiple different environments and tools for different tasks on Windows.

Installing MSys2

Download and run the MSys2 installer from GitHub releases Releases ยท msys2/msys2-installer (

Enter your desired Installation Folder (short ASCII-only path on a NTFS volume, no accents, no spaces, no symlinks, no subst or network drives, no FAT).

When done, click Run MSYS2 now. Remember click Finish with the check box checked.

Setup MSys2

Before you install your tool chains, update the package database and base packages. Unless your setup file is very recent, it will take two steps. First run this command below.

pacman -Syu

Then close the windows, run “MSYS2 MSYS” from the Start menu. Update the rest of the base packages with pacman -Syu again.

pacman -Syu

Now MSYS2 is ready for you. You can install some tools like mingw-w64 GCC to start compiling:

pacman -S --needed base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake

Note the “mingw-w64” before each package indicate that this package can only be access from “MSYS2 MinGW x64” in start menu. Each one of these are isolated from each other (for example, Clang x64 won’t be able to access the packages that was installed on MinGW x64).

After that, IDEs like vscode, CLion should be able to detect tool chains automatically.

vs code

Windows Terminal Support

Though WSL isn’t a viable choice to compile windows binary file using GUN tool chains, the Windows terminal might be the best terminal app on windows.

Insert the example profiles shown below under the profiles key. Note that the examples assume that you have MSYS2 installed under C:\msys64.

    "commandline": "C:/msys64/msys2_shell.cmd -defterm -here -no-start -mingw64",
    "guid": "{17da3cac-b318-431e-8a3e-7fcdefe6d114}",
    "icon": "C:/msys64/mingw64.ico",
    "name": "MINGW64 / MSYS2"
    "commandline": "C:/msys64/msys2_shell.cmd -defterm -here -no-start -mingw32",
    "guid": "{2d51fdc4-a03b-4efe-81bc-722b7f6f3820}",
    "icon": "C:/msys64/mingw32.ico",
    "name": "MINGW32 / MSYS2"
    "commandline": "C:/msys64/msys2_shell.cmd -defterm -here -no-start -msys",
    "guid": "{71160544-14d8-4194-af25-d05feeac7233}",
    "icon": "C:/msys64/msys2.ico",
    "name": "MSYS / MSYS2"

You can make one of the MSYS2 profile default by setting the defaultProfile key to the guid value of one of the profile entries.

One Comment

  1. Pingback: Simple starter guide: Installing OpenCV (Windows) – Phyllali's Blog

Leave a Reply