Software I like: Cygwin, MinGW, etc.

Cygwin icon Cygwin is a collection of GNU tools that provides a Linux-like environment under Microsoft Windows; the DLL cygwin1.dll provides the Linux API functionality.

MinGW/msys icon MinGW is a minimalist GNU Linux environment for developing native Microsoft Windows applications; it makes use of DLL's that are provided by Microsoft as part of Windows.

I don't really quite get all the distinctions. In the context of a question about symlinks, see this posting for a brief discussion.

Cygwin

Cygwin is installed by downloading and running a setup programme, e.g., setup-x86_64.exe. Subsequent updates are done by rerunning the same programme. I use C:\cygwin64 as the Root Install Directory and D:\CygwinPackages as the Local Package Directory.

A Cygwin shell is started by doing
Start ▶ All Programs ▶ Cygwin ▶ Cygwin Bash Shell,
or Start ▶ All Programs ▶ Cygwin ▶ Cygwin64 Terminal.

To compile my software I think I need to explicitly install the following packages, although I've become a bit confused about when and how I installed what: binutils; gcc-fortran and gcc-g++; make; ncurses things; libjpeg* (Cygwin has version 8, I assume 6.2, Cygwin no longer has it even as an obsolete package; 8 should be source compatible with 6.2 (ref) and libjpeg-turbo should even be binary compatible); libpng12-devel. I've made at least some of my software run under Cygwin in the past, but today (2015 Apr 11) I'm giving up after getting build messages of the form
../sysdep/file_x_.c:153:(.stab+0xc08): relocation truncated to fit: R_X86_64_32 against `.text'.

To run an X11 programme (e.g., one of my graphics programmes), one needs to run the XWin server (FAQ). Normally it would be run by doing Start ▶ All Programs ▶ Cygwin-X ▶ XWin Server. But …

tty or not tty

It is sometimes desirable to define a Windows environment variable CYGWIN = tty. Among other things, this prevents ^C from being mapped to ^G, which messes up Emacs commands (ref 1, ref 2).

However, setting tty this way causes Start ▶ All Programs ▶ Cygwin-X ▶ XWin Server not to work properly. For example, the XWin server may start but some applications cannot be started by right-clicking the Cygwin/X Server icon in the system tray and using the Applications menu.

A workaround is to do startxwin& (or perhaps startxwin -- +bs) manually in a Cygwin shell (ref). This is analogous to startx in ‘real’ *n*x.

Need for rebaseall

Sometimes Cygwin gets itself into a condition in which things don't work very well any more and beastly error messages appear, such as

Doing vfork: resource temporarily unavailable
This may be because the DLL's need to be ‘rebased’ and the solution is to run something called rebaseall (in the package rebase). See this post by Eric Blake for a hint about what's happening. To run rebaseall: exit from anything related to Cygwin; do Start ▶ All Programs ▶ Accessories ▶ Command Prompt; cd to the Cygwin binary directory (e.g., C:\cygwin\bin\); run ash (a shell); and give the command ./rebaseall -v (ref1, ref2).

Cygwin Ports

In addition to the packages available by default, there are also many packages available from the Cygwin Ports project. There are good instructions there for how to tell setup.exe to get things from ftp.cygwinports.org. (Zoltan Hawryluk posted detailed instructions for Installing Cygwin and FontForge for Windows.)

MinGW

I have even less experience with MinGW than with Cygwin. MinGW (Minimalist GNU for Windows) 'is a minimalist development environment for native Microsoft Windows applications' and is used with MSYS, a shell command-line interpreter. I don't really understand why the name MSYS exists distinct from the name MinGW. MinGW contains compilers, binutils (assembler, linker, archive manager) and installers. MSYS includes a shell (command-line interpreter) and a few Unix tools.

Last update on SourceForge dated 2018 Jul 13, as of 2021 Apr 4.

In detail: MinGW includes package-list, autoconf, automake, basic-bsdtar, binutils, bzip2, cygutils, expat, gcc3, gcc4, gcc-tools, gdb, gendef, gettext, gmp, libarchive, libiconv, libtool, make, mingw-get, mingw-utils, mgwport, mpc, mpfr, pexports, popt, pthreads-w32, runtime, xz, zlib, libunistring, pdcurses, base & autotools.
MSYS includes package-list, autoconf, autogen, automake, bash, binutils, bison, bzip2, console, core, coreutils, crypt, cvs, cygutils, dash, diffutils, diffstat, expat, file, findutils, flex, gawk, gcc, gdbm, gettext, gmp, grep, groff, guile, gzip, help2man, inetutils, less, libarchive, libiconv, libtool, libxml2, lndir, lpr-enhanced, m4, make, man, minires, mintty, mktemp, openssh, openssl, patch, perl, popt, rebase, regex, rsync, rxvt, sed, tar, termcap, texinfo, unzip, vim, w32api, wget, xz, zip, zlib, mksh, base, developer-toolkit & system-builder.

Related projects are:

By default, MSYS uses bash as its shell, but run under the name sh which changes it behaviour. The dash shell is also available and can be installed with the command
mingw-get install msys-dash
At login, sh, dash and bash all read ~/.profile; bash (unless run as sh) also reads ~/.bash_profile and ~/.bash_login if they exist. (This is an oversimplification.)

MinGW does not support symbolic links (cf. thread of 2012 Mar 9–14).

Graphics libraries for use with MinGW are discussed under LibrariesAndTools. The link given there for GTK+ downloads is wrong; it should be http://www.gtk.org/download/index.php. There is a discussion there about whether it's best to get things related to GTK+ from http://sourceforge.net/projects/mingw/files/ or directly from the GTK+ site, but the wording is confusing (cf. response to my query). Apart from MinGW and MSYS themselves, there is little at the SourceForge site and most of it is very old.

I downloaded the all-in-one .zip bundle of the GTK+ stack from http://www.gtk.org/download/win32.php I copied the include/cairo/ directory to C:\MinGW\include\. I copied bin\libcairo-2.dll to C:\MinGW\lib\. I had to change -lcairo to -lcairo-2 in cairo_test.libs. I copied libcairo-2.dll, libfontconfig-1.dll, freetype6.dll, libpng14-14.dll and zlib1.dll to ~\src\dip\ia32-mingw\.

TakeoffGW is/was a project that attempts to overcome some of the issues of MinGW, with a fork of Cygwin's installer. In a dismissive cygwin-talk thread it was mentioned that, as of 2010 May 31, 'in just a few weeks, the MinGW folks are going to (finally) release an installer of their own, which is extensible and allows to "include by reference" other repositories of addons' (ref). I guess that refers to mingw-get.

Installing things

This section describes what I did in 2011-2015 to get MinGW ready to build my software. As of 2021 Apr 3, I've started to use Mingw-w64 and will have to revisit all this.

Laurence Muller has a description of How to upgrade your MinGW with commonly used libraries (2010 Mar). See also kemovitra's MinGW Tutorial: Compiling GTK+ 2.16.4 for Windows (2009 Jun), and the GTK+ download page for 32-bit Windows (there is also an experimental page for 64-bit Windows).

To install libjpeg: in the MSYS shell I did

To install zlib (required by libpng):

To install libpng:

To get curses, I did
mingw-get install libpdcurses. In C:\MinGW\lib\ I made copies of the libpdcurses files, naming them libcurses.

dir.h is in include rather than in include/sys/. In any case, I've switched to including <dirent.h> rather than <sys/dir.h>.

To get the X11 headers, I downloaded X11include.tar.gz from XportMinGW and copied the include/X11/ directory into C:\MinGW\include\. I also downloaded X11lib.tar.gz and copied its libX11.a and libXau.a into C:\MinGW\lib\.

I've also made a number of changes in my source code, mostly because gfortran detects different errors than g95 does.

Mingw-w64

This 2007 fork of MinGW ‘delivers runtime, headers and libs for developing both 64 bit (x64) and 32 bit (x86) windows applications using GCC and other free software compilers’. The relationship between this and the MinGW project appears to be unfriendly, with issues revolving around licensing (ref).

Last update on SourceForge dated 2021 Apr 3 as of 2021 Apr 4.

mingw-w64-install.exe offers a few alternatives, including either 32-bit (i686) or 64-bit (x86_64), and installs them into different directories under Program Files\mingw-w64\ or Program Files (x86)\mingw-w64\, and installs multiple Run terminalshortcuts under MinGW-W64 project in the Start Menu. The Run terminal shortcuts all look the same unless you edit them.

There's also a multilib version which I haven't looked at yet.


R. Funnell
Last modified: 2021-04-04 09:20:41