Cygwin

Cygwin is an open-source implementation of the POSIX system interface for Microsoft Windows, and also a distribution of open-source software built on that implementation.

See Also

Building Tcl and Tk with Cygwin
MinGW
gcc & binutils for MSYS
MSYS
A GNU development environment which is purely MS Windows based - no attempt to provide POSIX functionality.
Problems when using Cygwin and the tcl that comes with cygwin [L1 ]
Tcl/Tk on Xwindows emulation on XP using Cygwin
Building Tcl under cygwin with MINGW
Open-source tools for Cygwin on Windows
Provides a binary distribution of Tcl/Tk 8.5.11 for Cygwin, and also some instructions on building Tcl/Tk for Cygwin.

Description

Cygwin provides a DLL, cygwin1.dll, that in turn provides the POSIX system interface API to programs that link against it. It can be downloaded as a binary distribution that includes a large collection of Unix software that has been built against it. Cygwin is compatible with all versions of Windows from 95 on.

Cygwin includes GCC and a development environment in which Unix software distributed in source form can be built and installed. It also includes an X server.

Cygwin consists of an emulation library and a collection of Unix (and GNU) programs ported to that library, including bash, gcc, and Tcl/Tk. The Unix tools can be used from the bash shell or from the usual Windows command shell, a.k.a. DOS prompt.

Cygwin currently includes Tcl-8.5.18, Tk-8.5.18, and some other Tcl packages. There is also a collection of cygports scripts that automate the task of building Tcl 8.6.4 (or newer) and a large number of packages under Cygwin.

File Names Differing in Case Only

By default, Windows does not treat file names in a case-sensitive manner. This can cause silent data loss in sets of files created under a different assumption. Make sure to change the obcaseinsensitive registry setting and reboot, as described in Cygwin User's Guide .

FAQ

How does buiding software in a Cygwin environment differ from other Unix environments?

At the highest level, not by much. Once Cygwin's GCC and standard build tools are installed, it's often a matter of following the stereotypial process:

./configure
make
make install

What targets does the Cygwin GCC support?

Cygwin GCC supports the Cygwin platform as its native environment, and, using the -mno-cygwin option, also supports Windows as a non-native target. Additionally, Cygin includes a build minGW and also a build of minGW-64, both of which target the Windows platform.

Can software built for the Cygwin platform access the Windows API?

Yes. linking against cygwin1.dll does not preclude also linking aginst Microsoft platform dll's. For an example of this, see Snack. See also Tcl itself, which detects the Cygwin environment at build time, and configures itself to use some of the Windows API.

To build normal Windows executables, use the Cygwin gcc with Mingw http://www.mingw.org/ , a version of which is included with cygwin. This configuration can be used to compile the standard Tcl/Tk distribution into a standard Windows executable. See win/README in the Tcl/Tk distribution for details.

Are there any special add-on packages that would be useful when developing with Cygwin?

TV: you may want to type

startx

assuming you clicked XFree86 in the 'setup' installer.

That gives you X Windows emulation on ms windows, that is a big window which has contents just like on an X server/client setup, like on Linux. In fact it easily cooperates with Linux, by changing the DISPLAY variable to some other machine running either the same or linux (with gui) or Unix, and setting xhost +your.machine on the other machine, and running a shell on you machine, it appear on the other. Maybe worth a separate page, but I guess many will know. The reverse is also fine, the main screen can be referred to as :0, so

export DISPLAY=some.machine:0

Note that bash requires the use of export to set shell variables, 'set' results gets lost.

in any terminal window on the X screen you can type

xterm &

to get more terminals, when the rubber lining appears click somewhere to place the window. To get a nicer window manager, use ps to find the PID (process ID) of 'twm' the standard window manager, kill it with

kill <PID>

and type

wmaker &

in some terminal's shell. Now openstep will start, which looks pretty cool and works comfortable.

Text editors supplied are emacs (me) and vi, and maybe more. DIR becomes ls, more and pipes | are available. Find works like:

find -name '*somename*' /cygdrive/c/cygwin/... -print

Bat files become .sh script files, slashes go the other way around as in windows (/).

The most important command is probably 'man' which stands for manual.

man man

will give you the manual page for the man command. man gcc can also be useful, but lengthy.

wish

will give you the builtin (fairly recent but usually not completely the same as standard) tcl/tk. Add an ampersand to start it in the background, so your shell can continue.

For the advanced:

gdb

or as of recently

insight

is a powerful graphical C debugger, with interface based on tcl/tk (hardcoded, but fast).


Is Joe English the resident expert?

jenglish 2002-05-18: Absolutely not. I'm as confused by this stuff as everyone else.. But see [L2 ] for something I'm working on that may eventually help.

Mumit Khan appears to be the expert.


TV Anyone try porting tcl/tk in some version to the FREEX server with cygwin?

escargo 2003-08-27: What's FREEX? Do you mean the XFree86 X server?


Environment Quirks for ActiveState Tcl and Cygwin

When using a Tcl interpreter which is started outside of the cygwin environment, make sure to check your environment variables from within Tcl if you are not getting the results that you expected. I was having fits trying to get the arch[L3 ] command output into Tcl. The problem as it turned out was due to discrepancies between the environment variables. Thus a simple set env(HOME) /path/to/home fixed my problems. The moral of this story is: Before you pull your hair out because you aren't getting the output you expected, check your environment settings. A big thanks to the people on #tcl at irc.freenode.net for helping me out with this.

LES 2004-04-11: I use Cygwin, but not the Cygwin Tcl. I prefer ActiveTcl. My $PATH has 21 paths, but when I use it from Cygwin/rxvt, I get 25 paths. Inspection revealed that Cygwin prepends 4 paths to one's $PATH, and if you already have them in your $PATH (say you want to call GNU programs from outside Cygwin), they will be repeated in the output: D:\cygwin\usr\local\bin;D:\cygwin\bin;D:\cygwin\bin;D:\cygwin\usr\X11R6\bin; . Note that D:\cygwin\bin appears twice, which leaves me with three occurrences of that path in my $PATH. Go figure.

escargo 2005-08-25: I was trying to get a Tcl script to run in both ActiveTcl for Windows and Cygwin. I was looking for a good way to distinguish between the two environments. What I finally settled on was looking for the env(term) environment variable, which is set in Cygwin but not used in Windows. (It's not definitive, but it should work for most people.) I used that in a predicate to decide whether to add a path to my auto_path value so I could use packages already installed on Windows in the Cygwin environment.


Changing the title of a Cygwin bash window

just call cmd with an environment setter:

cmd /c title="My new title"

Are there any alternatives to Cygwin?

There are alternatives available as commercial, freely distributable, and open source. For example, certain editions of Microsoft Windows has available a POSIX kernel that has had a variety of names - Unix Services for Windows is one. A commercial product that can be used is MKS toolkit. David Korn wrote an alternative to Cygwin called U/WIN. And of course, one could use a Linux "live" boot image to use real Linux rather than one of the work-alikes.