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.
Currently, the best way to download MSYS is to choose the MSYS components you want from the download page and to extract them one by one in an empty directory. The MinGW developers are working on a new package manager to make this process automated.
For convenience, you can follow the instructions below to install 1.0.11. It currently requires less work, but the MSYS components installed are not up-to-date.
Installing MSYS (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.
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
FIXME: This is confusing, and mostly irrelevant. The entire section needs a complete rewrite; discussion of GNU autotools is not directly pertinent to the primary subject matter.
The autotools that are installed by MSYS DTK do not work well and can't build DLLs. If you need newer versions of autoconf, automake and libtool then follow these instructions.
We will install autoconf, automake and libtool.
- Unpack autoconf, automake and libtool to a directory of your choice.
- Install them with the 3 with the following command (avoid building in the source tree if possible):
../path/to/configure --prefix=/mingw && make && make install
- If make seems to be stuck in an infinite loop, csmake should probably be used instead.
- csmake is now part of MSYS 1.0.11, installed as "make"
As all the libraries will be installed in /mingw, PKG_CONFIG_PATH must be set. Optionally, if you want to get the cvs repository as a developer, CVS_RSH must also be set.
Open the file /etc/profile (C:\msys\1.0\etc\profile) with your favorite editor (make sure it uses LF line endings) and add:
You might also want to set CFLAGS. Safe options for MinGW are:
CFLAGS="-pipe -O2 -mms-bitfields -march=i686"
export HOME LOGNAME MSYSTEM HISTFILE
and modify that line by adding the four variables:
export HOME LOGNAME MSYSTEM HISTFILE CFLAGS PKG_CONFIG_PATH CVS_RSH
Now restart MSYS. You should now be able to use MSYS without problems.
- 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, "/mingw" should be used instead to avoid conflicts with msysdvlpr.
Building for MSYS
To build an application for MSYS (as opposed to using MSYS), users will need to install msysDVLPR. It contains the headers and libraries to for MSYS along with an old version of GCC and Binutils. Resulting programs will only run under MSYS.
Msysdvlpr should never be treated as a targeted platform. It should also be noted that msysdvlpr is unlikely to be updated in the near future.
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.