Revision of HOWTO Build MSYS from 2009, February 23 - 12:26

The MSYS binary release from the Current package or alternatively the Snapshot package.

The msysDTK binary release from the Current package.

The msysDVLPR binary release from the Snapshot package.

The wincon.h file from a recent version of the w32api package.

! Installation:
The MSYS release and the msysDTK release are packaged into a Windows style installer. Execute the binaries and make sure to use the same directory for the installation of both packages. You will need to untar the msysDVLPR package in the /usr directory. Then replace the /usr/include/wincon.h file with a newer version. Here are the steps:

! Configure and make:
You must first be in the MsysBuildEnvironment; execute msysdvlpr to enter it. The MSYS build process is designed so that you cannot build in the source directory. So, you need to create a separate build directory. I use the msys/rt directory of the source as the parent for my build directory.

'mingw32-gcc: command not found' or 'mingw32-g++: command not found' or : If this happens then the configure went wrong, and the files in the ./winsup/utils are trying to be built. Do the following so that configure doesn't try to use mingw32-gcc/mingw32-g++:

Rerun configure and make
The other solution is to install MinGW (which contains mingw32-gcc and mingw32-g++). It is preferable to install it in your /mingw directory. Please remember *not* to install MinGW and MSYS in the *same* directory !

'configure: error: ./configure failed for cygwin': you configured in the source directory, something that you shouldn't have done. Run a 'make distclean' and read the section above about how to configure correctly.

wincrypt.h, security.h, winbase.h compile errors. You probably installed a w32api and not just the wincon.h file. All your headers are thus pretty much messed up at this point. You should restart everything from a fresh install, or if you installed the headers in /usr/local, then just delete that folder (assuming you didn't install anything else).

! Debugging, Tracing, etc.
Building a debuggable MSYS dll. |

When debugging I like to not optimize the binary output as optimization tends to change the debugging information. So I set a variable like so: ``ccflags='-O0 -g -fnative-struct -DDEBUGGING=1 -DTRACING=1''. This will allow the debugging data to relate directly to the line of source being executed.

ccflags='-O0 -g -fnative-struct -DDEBUGGING=1 -DTRACING=1

make clean

make CFLAGS="$ccflags" CXXFLAGS="$ccflags"

Installing the dll full of debugging information. |

One of the great things about MSYS is that you can have more than one version of the dll running at the same time. For the list below let's assume you have MSYS installed in C:\msys\1.0:

copy the desktop shortcut and modify the properties to point to the debug/msys.bat

Regression testing |

Unfortunately I haven't kept up with the dejagnu testing that was already present in Cygwin. One of the reasons is that I'm not setup to execute dejagnu. I do have separate regression tests I use to check the pathing code. I need to add these to the CVS source so that others may use them.

Tracing |

When you build MSYS a program is created in the <top_build_dir>/i686-pc-msys/winsup/utils directory named strace.exe. Copy this program to the /bin directory, assuming you're debugging the CVS version of MSYS or a 1.0.11 or later release. You can then use strace to see the debugging output from the program. There is a lot of debugging information so be sure to specify an output file. Start the debug session like so, ``strace -o /tmp/strace.out foo''. You can use your production version of MSYS to ``tail -f /tmp/strace.out | less'' to watch the output. You may also use sysinternals dbgview to see the debug output.

Stack walking |

If you stack dump you will need to determine where in the code you've actually aborted. One of the methods I use is to create an output file of using objdump with the -S and -s switches. I then use gvim to view and find the addresses within the stack frame.

!Best of luck and happy hacking. Of importance; don't be shy about adding your tidbits of help. Others will appreciate the knowledge.