MSYS is a collection of GNU utilities such as bash, make, gawk and grep to allow building of applications and programs which depend on traditionally UNIX tools to be present. It is intended to supplement MinGW and the deficiencies of the cmd shell.
An example would be building a library that uses the autotools build system. Users will typically run "./configure" then "make" to build it. The configure shell script requires a shell script interpreter which is not present on Windows systems, but provided by MSYS.
A common misunderstanding is MSYS is "UNIX on Windows", MSYS by itself does not contain a compiler or a C library, therefore does not give the ability to magically port UNIX programs over to Windows nor does it provide any UNIX specific functionality like case-sensitive filenames. Users looking for such functionality should look to Cygwin or Microsoft's Interix instead.
Up to MSYS 1.0.11, all components of MSYS were distributed in one single installer you downloaded and ran. While convenient, this made it difficult to update individual components. So, all the MSYS components are now available as separate downloads managed by mingw-get (see Getting_Started (currently alpha release).
For convenience, you can follow the instructions below to install 1.0.11.
Previous MSYS versions (up to 1.0.11)
These instructions were based on the Enlightenment Wiki. Thanks to Vincent Torri for pointing them out.
The total size of the installation of MSYS/MinGW is around 110 MB. Be sure to have enough space on your hard disk.
- If you haven't already installed MinGW on your system, install MinGW in C:\MinGW. It is better to not install it in the same directory than MSYS, though there should be no problem since MSYS 1.0.11. In the installer, choose "Download and install", then "Current" (it will install gcc 4.4.0).
- Install MSYS 1.0.11. I usually install it in C:\msys\1.0, but you can use any directory that you prefer.
Check http://sourceforge.net/projects/mingw/files/ for more recent versions of all these files.
- Next, the post install process will ask for the directory where MinGW was installed to. Enter "c:/mingw". If you make a mistake, you can change it by editing the "C:\msys\1.0\etc\fstab" file, make sure to use 'LF line endings. An example fstab may contain:
c:/mingw /mingw c:/java /java
- Install MSYS DTK 1.0 in C:\msys\1.0.
- Install MSYS Core 1.0.11. It is an archive. Untar it in C:\msys\1.0.
- Set the environment variable HOME to C:\msys\1.0\home
Now you should have a cyan "M" link on the Desktop. When you double-click on it, a terminal should be launched.
Using MSYS with MinGW
It is convenient to have your MinGW installation mounted on /mingw, since /mingw is on MSYS PATH by default. For this to work, just type (assuming MinGW is on c:\mingw):
mount c:/mingw /mingw
To install 3rd party library and applications which uses the autotools build system the following commands are often used.
./configure --prefix=/mingw make make install
Installing to "/usr/local" should be avoided, since the MinGW compiler won't look there by default.
Building for MSYS
To build an application for MSYS (as opposed to using MSYS), users will need to install the MSYS Toolchain. It contains headers and libraries for MSYS along with a patched version of GCC and Binutils. See HOWTO Create an MSYS Build Environment.
It should never be treated as a targeted platform. It is meant only as a means to update the MSYS components or the MSYS runtime DLL itself. Resulting programs will only run under MSYS.
MinGW build VS MSYS build
Some programs when used under the MSYS shell can be tricky. One such example is sed.
$ ls *.txt -1 | sed -e s/.exe/\&\!/g
Normally, sed will append "!" to the end of every .txt file, but if sed was compiled and link using MinGW, MSYS will treat it as a native application and will try to change "/" to "\" to compensate for the difference between UNIX path and WIN32, resulting in unpredictability when used under the MSYS shell.