This is an old revision of the document!


Understanding MSYS / MinGW

MinGW is a port of GCC and the GNU binutils that produces native Win32 binaries.

MSYS is a set of libraries and tools which emulate a Unix-like environment on Win32. MSYS tools are linked with a library that emulates a number of POSIX library calls which do not exist in the Win32 API, and that translates file and directory names to a more Unix-like format. For instance, /c/windows/ in MSYS corresponds to C:\WINDOWS\. Because of this, MSYS is very slow, especially when it comes to I/O operations.

The important thing is that the an application built with MinGW is a native Win32 application which does not use the MSYS runtime library and hence does not experience this slowdown. However, this also means that many POSIX library functions are not available.

Microsoft's C runtime library implements a fair subset of POSIX, and MinGW adds some more (much of it as wrappers around Win32 API calls); in practice, well-written application-level code will work fine with minor changes. The real gotchas are the bits that compile just fine but mysteriously fail at runtime, such as fopen(): Windows uses CR LF line endings, so if you fopen() a binary file with r instead of rb, any LF characters read from the file will be expanded to CR LF. The same applies (in reverse) when writing to a file fopen()ed with w instead of wb.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • diana/windows/building/understanding.1270569597.txt.gz
  • Last modified: 2022-05-31 09:23:14
  • (external edit)