Tcl/Tk on Xwindows emulation on XP using Cygwin

Theo Verelst

(well, ehr, the below obviously probably isn't working anymore, though it's my standard socket for various video stuff, feel free to try...) Jun 21 03 17:00 As a little test and a start to an interesting subject, maybe with BLT or in that area, this link (I'm not sure when this experiment will work, I want to try screen captures, too, preferably using tcl in the future) lets you watch the work on the subject, when the encoder is working, that is. It probably show windowmaker, which is a NextStep windows manager which runs on XP in this case, where tk windows can be run under that server instead of under the normal XP windows system. Good for cross development, neater, more flexible, and a good test for the Tk sources under the cygnus compiler. Do try this at home, though I guess the idea and work is a bit far out, and one needs a decent amount of memory, though I guess a 64 M machine should be fine. (this image, it's just a small jpeg, on probably means I captured it recently, but not as stream)

(jun 20 '03) At quite an unchristian time I though I'd give it a go anyhow, and see if I could make use of some possibilities to give tk a better graphical dwelling place while running XP.

The idea is that of course we can have either linux/unix or other X machines with tk windows, or windows machines with them, but in this case we can have both. I installed cygwin, added the XFree86 X windows emulator for under windows in the installation list, and even the wmaker NextStep (cool graphics), the X headers, and of course most of the compiler and development environment, it never hurts to have linux-like tools available while still having access to the windows only stuff (such as usb modems, tv extensions, certain programs, specific drivers).

Cygwin can compile tcl/tk in principle, and I think some people reported that the ming part can even without needing to use the cygnus.dll, but I wanted to go the other way, and use the unix emulation, and especially the XWindows support.

After having picked a download site and a few installation directories, and checking the desired packages in the list, and having choosen 'install from internet', the whole download and installation can go effortless, except you need a fast internet connection of a lot of patience and phone quarters.

It is whorth it though, just click on the cygnus icon, and you have a unix shell and good gcc compiler.

Image TV Wiki xfree1.jpg

Now type


And you should have a XWindows simulator in a windows window (I tested on XP, but used it before on NT, 95, 2000 server) in vanilla, 15 years ago decency.

Now the fun is to get tk crazy enough to appear on that simulated X screen, or of course on some networked linux computers' screen...

I used the tcl and tk 8.3 sources I used on linux the other they, and which install straight there, and expected quite less luck here. First, untarring and configuring tcl would be including lack of load and shared libraries, or I'd have to use dll's on unix.. Make-ing tcl works not straight away, though maybe I've cut cygwin short of some wieldy internationalisation library, compilation breaks (latest cygwin) on a time variable, which I simply kicked out by making the whole procedure which contains it return straight away, which gave me only a hanging application at some point I think, but that of course should be done neater.

After that, and make install, tclsh would start up and seem to work (it's late, I didn't run make test). Tk started by freaking out, but then I put the configure options down where they belong, downloaded the X headers (...) and made a xdefaults source file point to the unix version instead of the windows version associated automatically by some ifdef and constructions, and compilation got through until at the end the anticipated 'wish' was generated.

Make install is needed, unless probably one would set some env variables, after which the great test: will a xwindow perifery wait to be put in place after wish is started...? It did.

And bwise runs in it as shown in the picture above.

I'll see what I can reasonably enough make available for download.

PNG is a much better format for screenshots - it doesn't get all those fuzzies.

escargo 24 Sep 2003 -- I just updated to the latest Cywin (1.5.5-1). In my cywgin file system I have /usr/bin/wish and /usr/bin/tclsh. These appear to be 8.4 implementations. However, when I start them from an XTerm on my X Windows implementation, wish hangs. If I start them from the cygwin shell, wish works on the Windows desktop, but not on X Windows. Is this behavior new? Is the behavior intended? I was hoping that running wish from an XTerm would have wish create windows on my X desktop, not my Windows desktop.

TV Oct 4 03 A wish which runs under cygwin X, on top of windows, is not a simple matter in terms of implementation, irrespective of the choice of the starting shell. I compiled wish 8.4 to DO run in the way that it as shown above runs on X on XP, but that relies completely and heavily on the cygnus unix emulation layer to get rid of the many inconsistencies between windows and unix sources. Having a more elaboratedly worked at version in cygwin of course would be a very good idea (any funds available?), as it seems the above version can run stable.

GPS 24 Sep, 2003: Cygwin emulated support has been dropped in recent Tcl/Tk releases. Mo Dejong pulled the support, because nobody came forward to maintain it. The Cygwin build was getting broken too often. Mumit Khan submitted the patches for MinGW and Cygwin (8.4.x patches IIRC), so he may be able to help you. Now we have more people using MinGW (including myself with -mno-cygwin) for Win32 builds, so it tends to work pretty well.

TV Oct 4 03 The idea of the emulation would be to compile under windows as-if one is on a unix system, so it would make most sense to either use the cygwin compiler (gcc) to make a windows build of tcl/tk, which I think works fine, even without the --no-cygnus (I don't know exactly, I'll have a look when I return from france) option, in which case the cygnus environment provides a strong compiler environment primarily, and alternatively, one should be able to use the cygwin emulation layer for what it is intended, as of recently including the X emulation, which requires a unix-type of build, except that it will yield a windows type of executable with cygwin stubs for file/socket/etc and with X server access.

And, honestly, some of the ideasyncracies which go with for instance the /cygdrive/c/.... file paths, which make some scripts unhappy.. And of course there is the shared library issue, I don't think cygwin's emulation layer lets you read in .so files. Also I'm not sure it will fix stdio problems as exist under windows, then again, it might, which would be strong.

I think there is nothing much against using a sourceforge supplied tcl/tk under cygwin, either precompiled or self-compiled, which is easiest for the windows-window version, just make sure it comes first in your path, or change the /bin/wish symbolic link to what you prefer.

Category Porting