MSYS

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.

Installing MSYS

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

  • 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.

bug in MSYS-1.0.11.exe

The setup program MSYS-1.0.11.exe contains a bug.

I'm installing MSYS on Win98SE. When running the post-install script, there is a couple of "- Cannot open" errors :

  • D:\MSYS\postinstall>..\bin\sh.exe pi.sh
  • This is a post install process that will try to normalize between your MinGW install if any as well as your previous MSYS installs if any. I don't have any traps as aborts will not hurt anything. Do you wish to continue with the post install? [yn ] y
  • - Cannot open
  • Do you have MinGW installed? [yn ]
  • Please answer the following in the form of c:/foo/bar.
  • Where is your MinGW installation? D:/MinGW
  • Creating /etc/fstab with mingw mount bindings.pi.sh: line 66: cannot create temp file for here document: Permission denied
  • Normalizing your MSYS environment.
  • You have script /bin/awk
  • You have script /bin/cmd
  • You have script /bin/echo
  • You have script /bin/egrep
  • You have script /bin/fgrep
  • You have script /bin/printf
  • You have script /bin/pwd
  • Renaming D:/MinGW/bin/make.exe to mingw32-make.exe.
  • - Cannot open
  • D:\MSYS\postinstall>pause
  • Press any key to continue . . .

Moreover, the installed D:\MSYS\msys.bat has the unix-style LF end-of-lines instead of the dos-style CRLF.

When running "D:\MSYS\msys.bat -norxvt", the "- Cannot open" error also happens. I think there might be some problem with the "sh" program.

Re: bug in MSYS-1.0.11.exe

keith's picture

These are known issues. The LF vs. CRLF line ending issue is a packaging bug, which should be addressed fairly quickly, (but I am not the maintainer, and cannot say exactly when he will complete the repackaging exercise). The "cannot open" issue arises because, in fixing another problem, a dependency on a feature which is unsupported in Win9x was introduced. The cause is known, and a work around is under investigation. Please be patient. We will endeavour to continue to support you, but your choice of a now-obsolete operating system makes that more difficult for us, and you will become increasingly prone to this type of issue.

Re: MSYS

I've just installed the release version 1.0.10 according to the instructions, and things seem to work -- thanks! Without wanting to look ungrateful, I have some comments:

I didn't update bash or coreutils, because there are no links. (Yes, I know I could go and look. I can indeed find some files that look like coreutils, but I'm then not sure what to do with them safely. I would have appreciated step-by-step instructions for the m4 update -- save to c:\msys\1.0, then "bzip2 -d m4-1.4.7-MSYS.tar.bz2" and "tar -xf m4-1.4.7-MSYS.tar". I *am* a newbie.)

I didn't understand the command (../path/to/configure) in the box just after the text "Install them with the 3 with the ..." (text which I also didn't understand). The Enlightenment wiki suggests "./configure" and "make install", and this worked. (I made the edits to C:\msys\1.0\etc\profile before I did this -- I don't know if that helped.)

It would have saved me a *LOT* of time to be told to expect printf not to work unless immediately followed by fflush(stdout);. I had a working system (except for this bug) during several attempts to reinstall, and didn't realise! See https://sourceforge.net/forum/save.php?forum_id=338575.

Also, I seem to have been hit by a restriction of how much memory can be allocated to a fixed-size array in a C program. This may or may not be related to a Vista problem (http://www.trnicely.net/misc/vista.html), though I'm running Window XP. This seems to be cured by using malloc.

Thanks, though!

Why is MSYS for MinGW so slow in compiling

When I ran Linux on a 3GHZ machine(debian), I could build red5 and xuggle in a few minutes .
Now I have a 3+GHZ machine running MSYS and MinGW(WINDOWS XP ).It took 10+ hours to compile...(I had add
alias clear=clsb
PKG_CONFIG_PATH="/mingw/lib/pkgconfig"
CVS_RSH=ssh
CFLAGS="-pipe -O2 -mms-bitfields -march=i686"
export HOME LOGNAME MSYSTEM HISTFILE
export HOME LOGNAME MSYSTEM HISTFILE CFLAGS PKG_CONFIG_PATH CVS_RSH

for my MSYS env)
and i found when i use ant for red5 and xuggle it would slowly slowly slowly.....
Can someone help me out here? What am I doing wrong
Any help is appreciated, thanks for reading,

Re: MSYS

Hibou57's picture

It seems there are trouble with mSys and make.
The mSys make version seems to be 3.79.1, while to build some sources, make 3.80 is required.
The MinGW make is 3.80.
Unfortunately, the MinGW make is a Win32 make, while the mSys make is required to be a POSIX make.
Overwriting mSys make with the executable from the MinGW bin directory obviously does not work.
Running /bin/mingw/mingw32-make instead of make from the mSys console, does not work better.
Is there a location where a make 3.80 for mSys can be found ?

EDIT - Oh, I've finally found it here : http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=24963

Gonna try it.

EDIT 2 : Yes, it works very fine.

Re: MSYS

Thanks; I really appreciate the effort y'all put into making MinGW

Re: MSYS

(sorry for bad syntax writing) ahh....and what if i install and use mingw only without msys...could i compile and build my code successfullly?

Re: MSYS

keith's picture

Yes; there are many masochists who do just that :-)

Re: MSYS

I got msys working quite well...compiled a few single-file c and c++
programs, so I decided to give it the 'acid test'...try to run a real
'./configure' cmd against a real (Linux-source) package.

It actually makes it QUITE FAR into the configure-script before it
chokes. That final few lines of output are:

checking for gtkdoc-check... no
checking for ppoll... no
checking for dlopen in -ldl... no
configure: error: dynamic linking loader is required

Any idea whether/how to solve the 'dynamic linking loader is required'
issue?

Re: MSYS

i download and unpack autoconf, automake and libtool in c:
and type in msys : configure --prefix=/mingw && make && make install
but it report error
what can i do to run it?
when i type < ./configure> in msys it reported no such file or directory

Re: MSYS

keith's picture

You could begin by reading all of the comments below. If you don't find an answer there, then please use the mailing list; (but first, please search the archives, because I've already given definitive instructions for building autoconf, and I'm getting tired of repeating myself).

This wiki is not a forum for discussion of usage issues.

Re: MSYS

I'm stuck on installing autoconf. I unpacked autoconf-2.63 and typed the command

configure --prefix=/mingw && make && make install

This resulted in the following error.

make[3]: *** [m4sugar.m4f] Error 1
make[3]: Leaving directory `/c/msys/autoconf-2.63/lib/m4sugar'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/c/msys/autoconf-2.63/lib'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/c/msys/autoconf-2.63'
make: *** [all] Error 2

Any suggestions?

Re: MSYS

keith's picture

Please, take this to the mailing list. Better still, search the mailing list archives, because I've answered this already!

In any case, what was the error? You've shown us make's unwind path, but not the actual error diagnostic. Looks like you've tried to configure an `in-source' build. You shouldn't do that! Please read the instructions again. Also, read all of the follow-up comments, particularly the one instructing you not to build `in-source'.

Re: MSYS

Manual installation

I'd like to ask if there're manual install instructions for MSYS.

I want to install MSYS in a way similar to that of MinGW, i.e. download separate packages and then integrate them one by one.
The sourceforge repository has a collection of such packages as bash, coreutils, &c., but I don't know how to put them together to make a working copy of MSYS.

kbhit() - fixed - kinda

1. // kbhit.c - from a microsoft example

2. #include <conio.h>

3. #include <stdio.h>

4. int main( void )

5. {

6. // Display message until key is pressed.

7. while( !_kbhit() ) ;

9. // Use _getch to throw key away.

10. printf( "\nKey struck was '%c'\n", _getch() );

11. }



I found the above code compiles fine using mingw compiler or the cygwin g++ compiler (use the -mno_cygwin compile flag).

It will run properly in a MSDOS window on a XP windows machine.

It will not run properly in a cygwin xterm window running on a XP windows machine.

It will not run properly on a Ubuntu xterm window and using wine.

I believe the problem lies with how an xterm window handles keyboard input.

So anyhow, you can run the program, but only in a DOS window.

Not a fix, but it is a reasonable work around.

Re: MSYS

niXman's picture

Hi!
Why at building of autoconf I receive message:
Makefile:678: warning: overriding commands for target "install
Makefile:574: warning: ignoring old commands for target "install
cfg.mk:20: *** Recursive variable "PATH references itself (eventually). Stop.
Why ???

Re: MSYS

keith's picture

Did you try to build it `in place', (i.e. running configure and make in the source directory)?

Short answer: don't do that; use a separate build directory, and run configure specifying the path to the source:

path/to/configure --prefix=/mingw/local ...
make
make install

Alternatively, if you must build `in place', then you must use csmake, (or cpmake), instead of make.

Long answer: autoconf specifies rules to remake the file called `INSTALL', in the top source directory, in addition to the dummy `install' target, to perform the installation. When you invoke make in the top source directory, the presence of the `INSTALL' file, given the case-insensitive property of the MSW file system, conflicts with the `install' rule; `make install' is interpreted as `make INSTALL', resulting in the failure you report. Using a separate build directory seems to resolve the conflict. Using csmake or cpmake subverts the case-retentive property of the MSW file system, to pretend case-insensitive behaviour -- that's an unsafe pretence, in general -- so avoiding the conflict.

Re: MSYS

I've followed the wiki to install MinGW and MSYS, but I've found that make freezes at random spots in anything I try to build. I've changed to csmake as recommended in the wiki, but the problem remains. Suggestions welcome.

Re: MSYS

earnie's picture

Please use the mingw-users@lists.sourceforge.net mailing list for this support.

Re: MSYS

There is no error, it just stops at a random spot, forever. If I kill csmake, and then restart it, it'll continue on just fine for a while, until it freezes again.

Re: MSYS

keith's picture

Seems remarkably like the Logitech QuickCam driver, about its nefarious viral business.

As Earnie says: `use the mailing list'. Better still, search the archives, or consult the FAQ; this is a known problem, and the answer will be found there.

Re: MSYS

It says here:

>> It contains the headers and libraries to for MSYS along with an old version of GCC and Binutils.

Is there any reason for using these older versions of GCC and Binutils? I mean, is there anything specific in the source code that won't work with newer versions?

It also says, that

>> It should also be noted that msysdvlpr is unlikely to be updated in the near future.

So, presumably there are no plans for anything else to replace the msysdvlpr with something else?

Re: MSYS

earnie's picture

msysDVLPR is only for developing MSYS. The state of the MSYS runtime library is such that it doesn't support some of the newish features that have been developed by Cygwin. Therefore, until someone adds enough features to MSYS, it must use the oldish versions of GCC and binutils.

Re: MSYS

No reason for the old versions, its just that it was never updated.
I don't know if msysdvlpr will be updated though, it hasn't changed since 2003, at least according to sourceforge.

Re: MSYS

From this post: facing error making autoconf ...

...if you use only the msysDTK-1.0.1 package, that installs only m4-1.4, which is too old. However, the solution is *not* to go build a native m4 to replace it; you should install the m4-1.4.7 update, which you will find as a separate download, in the same place as the original package:

Current Release: msysDTK-1.0.1

m4-1.4.7-MSYS.tar.bz2

Editor modified content

Re: MSYS

particularly during the installation of the updated commands:

the directory /usr/bin in Msys is different to the windows subdirectory [Msys/1.0]/usr/bin;

particularly when installing the 1.4.7 M4, it installs to the windows/usr/bin directory, you then need to move it, overwriting the 1.4 M4 in [Msys/1.0]/bin, that is the directory that *Msys* calls /usr/bin [!]

similarly once autoconf is installed, its binaries need moving too, etc..

Re: MSYS

earnie's picture

It is expected that you are using the MSYS tar command and are in the root / directory to extract the archive file. Else you have to move it as you say.

MSYS :mkdir not found

I am trying to use msys as a make for netbeans, when i try to compile a program, it gives me this problem "mkdir not found" please help me

Site Status

Site maintenance completed May 25th, 2012 at 12:38 UTC