MSYS

About 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

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 "Candidate" (it will install gcc 3.4.5).
  • Install MSYS 1.0.10. I usually install it in C:\msys\1.0, but you can use any directory that you prefer.
  • 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.

Recommended updates for MSYS

MSYS Base System contains numerous updates for MSYS. It is recommended to install the following updates:

  • Bash
  • Coreutils
  • m4

Using MSYS with MinGW

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.

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:

PKG_CONFIG_PATH="/mingw/lib/pkgconfig"
CVS_RSH=ssh

You might also want to set CFLAGS. Safe options for MinGW are:

CFLAGS="-pipe -O2 -mms-bitfields -march=i686"

just before

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.

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

I followed these instructions step by step to install MSYS. But when I tried to install the update of AutoConf, I always failed. I tried two days, and no luck at all. Does anyone know how to fix that problem? I tried to run the installation in a temporary directory and used the command ../autoconf 2.63/configure --prefix=/mingw and got the following error and a window poped up showing Sh.exe is accessing a 0x0000000 memory location:

( I also tried to run the installation in the directory of autoconf 2.63, but still got errors. sometimes, it showed "Segmentation fault", sometimes, showed 'all-recursive errors", sometimes, showed "No working directory is identified". Even I ran the same command twice, I got different errors. My system is Windows XP, SP3. )

" .... echo positional parameters were not saved. fi

test \$exitcode = 0) || { (exit 1); exit 1; }

( as_lineno_1=\$LINENO as_lineno_2=\$LINENO test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } " ) 2>/dev/null checking for a BSD-compatible install... /bin/install -c checking whether build environment is sane... 0 [main] sh 100620 open_stac kdumpfile: Dumping stack trace to sh.exe.stackdump yes checking for a thread-safe mkdir -p... ../autoconf-2.63/build-aux/install-sh -c -d checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether /bin/sh -n is known to work... yes checking for expr... /bin/expr checking for GNU M4 that supports accurate traces... /bin/m4 checking how m4 supports trace files... --debugfile checking for perl... /bin/perl checking for emacs... no checking for xemacs... no checking for emacs... no checking where .elc files should go... ${datadir}/emacs/site-lisp checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for a sed that does not truncate output... /bin/sed checking whether make is case sensitive... yes 0 [main] sh 101028 open_stackdumpfile: Dumping stack trace to sh.exe.stack dump configure: creating ./config.status 0 [main] sh 101448 open_stackdumpfile: Dumping stack trace to sh.exe.stack dump 0 [main] sh 100852 open_stackdumpfile: Dumping stack trace to sh.exe.stack dump config.status: creating tests/Makefile config.status: creating tests/atlocal mkdir: `': No such file or directory mkdir: cannot create directory `': No such file or directory mkdir: cannot create directory `': No such file or directory config.status: creating man/Makefile mkdir: `': No such file or directory mkdir: cannot create directory `': No such file or directory mv: cannot move `./conf102160-28673/out' to `man/Makefile': No such file or dire ctory config.status: error: could not create man/Makefile 0 [main] sh 102992 open_stackdumpfile: Dumping stack trace to sh.exe.stack dump

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

Hi,

What exactly was the error message? How does it freeze up?

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.