Version 51 of Cygwin

Updated 2011-02-20 07:08:42 by LV

Purpose: discuss this Microsoft Windows development environment's pros and cons

What is Cygwin?

Cygwin is a freely distributable software package that provides a Unix-like environment on a Microsoft Windows system. It works with Windows 95, 98, NT, 2000, and possibly others. (See http://www.cygwin.com/ )

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.

A version of the XFree86 server for X Windows, with X Windows tools, has been ported to Cygwin. It is distributed separately.

Cygwin is free.

Questions about Cygwin

Where can I learn more?

http://www.cygwin.com/

Does Cygwin include Tcl and Tk?

Yes, but the version included is ported to the Cygwin environment and differs from the official Tcl/Tk code available from http://www.tcl.tk/ . The Cygwin version presumably lags behind the official releases. There also may be slight changes to get Tcl and Tk to compile under Cygwin, depending on what C compiler you use.

On the other hand, you have the opportunity to extend wish or tclsh with your own functionality by linking the cygwin tcl and tk libraries with your C-functions, possibly by using SWIG at http://www.swig.org/ .

Why are there such problems using TEA under Cygwin?

I believe the problems are threefold:

  1. historically cygwin was rather complex to install and setup for basic use (this is no longer true, I think),
  2. TEA itself requires the installation of extra Unixy packages on top of cygwin (autoconf, for example), and its entire operation is based around lots of implicit knowledge of Unix. When running on Windows, things which 'should work' (in the mind of the user) don't, and since it is a bunch of Unixy stuff (as opposed to pure Tcl) the user hasn't the faintest idea how to fix what went wrong (and nor should they have to!) -- these problems range from the 'wrong' use of backslashes vs not, wrong handling of paths which contain spaces, directories requiring to have (or not) a trailing forward slash, etc., etc. (i.e., lots and lots of fragility which the poor Windows user has been forced to inherit)
  3. TEA itself is full of bugs, on Unix as well as Windows (it could be true that Jeff finally fixed most/all of these bugs in early 2002 for the sampleextension, but that was a bit too late for most people, and obviously doesn't help with any extension which tried to copy the sampleextension before).

What compiler should I use with cygwin?

To build Cygwin executables, use the gcc included in the Cygwin package. This applies as well when building the Cygwin version of Tcl/Tk.

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 refered 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?

Absolutely not. I'm as confused by this stuff as everyone else. --jenglish. But see [L1 ] 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 27 Aug 2003 - 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[L2 ] 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 on April 11, 2004. 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 25 Aug 2005 - 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.

What is the state of Tcl and Cygwin in the 21st Century?

Can anyone address this question?


Comments on building the X11 Tcl/Tk on Cygwin

http://opencircuitdesign.com/cygwin/


See also