Using MSYS2 on Windows

Pedro França
2 min readJan 3, 2024

--

Using MSYS2 as a Linux terminal on Windows doesn’t have to be hard. In fact, with MSYS2 you can interact with most Linux features directly from Windows, granted that it’s included on MinGW.

So, with MSYS2 you can install MinGW packages in a Linux environment, which is best for those used to Linux and the pacman package manager.

In MSYS2, using the MinGW64 subsystem, you can interact with these packages.

First, it’s important to know that you can access the Windows File System from a MinGW64 terminal using cd .. until you reach the Linux root, then cd cto change directory to Windows C: . From there you can access all your files.

You can use pacman -Sl | grep <package-name>to find a package you want to install and then install it as if it was Linux. The package will come with a mingw64 or msys2 prefix, depending on the subsystem you’re using.

You can access the packages from the directory in which you installed msys2, changing to mingw64 if you’re using mingw64. The default directory name is msys64. You can check lib, includes and bin for inconsistencies you would encounter running a Linux system on Windows. For example, the GNU make binary in MinGW64 is called mingw32-make, something you would have to go to the bin folder to know.

I also encountered some unknown library names I had to check for in the lib folder. Dealing with Linux and programming in general means messing with these folders often.

If you can use pacman -Sland pacman -Sto install packages, then you’re mostly ready to use MSYS2 as a Linux machine, given that you’re used to Linux. You can also run Linux executables, make folder and files as if it was PowerShell for Windows.

It is useful to have a Linux terminal in which you can interact with the Windows File System. Thanks for reading, leave a Clap if you enjoyed the content!

--

--