X11-based Tcl/Tk Compile for Cygwin


Since I have instructions on how to compile all of the open-source EDA tools from the original source, under Cygwin, it is useful to round out the set of instructions by providing the detailed instructions on how to compile the X11-based Tcl/Tk source under Cygwin. Unfortunately, since I am not a Tcl/Tk developer, I can't rewrite the source code to ensure an easy and glitch-free compile. But the steps are relatively minor, and I can provide all of the tips for how to do it.

The Tcl/Tk that comes with Cygwin is configured to use Windows graphics, and is therefore not compatible with all of the graphical interfaces in the open-source EDA tools, which make X11 calls.

To get Tcl/Tk running with these tools requires compiling Tcl and Tk from source. This is not particularly easy, as the distribution does not compile without some tweaking (described below). To avoid compiling these, you can download the pre-compiled tcltk_x11_win.tgz file according to the instructions on the Tcl/Tk page. This will get you a working version, although not necessarily the latest distribution. If you want the very latest distribution or development version of Tcl/Tk and want to use it with the open-source EDA tools, you will need to follow the instructions below.

These instructions assume that the first step on the X11-based Tcl/Tk page has been followed, to download and install the necessary parts of the Cygwin distribution, including the X server and "gcc" compiler.

  1. In Windows, from a browser, get the sources for Tcl and Tk from The Tcl Developer's Xchange. In the upper left-hand corner, click on the "Download" link, then grab the two gzipped (.gz) files from the links. As of this writing, the current version of each is 8.4.11. These files preferably go somewhere like "C:\cygwin\usr\local\src\". This path includes the installation destination for the Cygwin package (C:\cygwin) plus the path from the Cygwin root directory (/usr/local/src/).

    Note that Cygwin normally uses forward-slashes, the syntax of UNIX systems, to separate directory names in the file system, which just correspond to normal Windows directories. Cygwin can also specify directories with Windows partitions, but using forward slashes, e.g., "cd C:/cygwin/usr/local/src".

  2. Launch a Cygwin terminal on the Windows desktop, and correct name where version and revision numbers may differ:
    1. cd /
    2. tar xfz tcl8.4.11-src.tar.gz
    3. cd tcl8.4.11
    4. cd unix
    5. Edit the file "tcl.m4" using your favorite editor. Go to the line beginning "Linux*)". Above this line, insert the contents of the file "tcl.m4.cygwin", available for download here.
    6. autoconf
    7. ./configure
    8. At this point, you may want to edit the file Makefile and change the line CFLAGS= to use the debug cflags instead of the optimized one.
    9. make
    10. make install
    11. cp tclsh.exe /usr/local/bin
    12. cd ../..
    The Tk compile in Cygwin goes like this:
    1. tar xfz tk8.4.11-src.tar.gz
    2. cd tk8.4.11
    3. cd unix
    4. ln -s tkUnixDefault.h tkWinDefault.h
    5. Edit the file "tcl.m4". Go to the line beginning "Linux*)". Above this line, insert the contents of the file "tcl.m4.cygwin", available for download here.
    6. autoconf
    7. ./configure
    8. At this point, you may want to edit the file Makefile and change the line CFLAGS= to use the debug cflags instead of the optimized one.
    9. make
    10. make install
    11. cp wish.exe /usr/local/bin
    12. cd ../..
    This will compile and install Tcl and Tk to the "/usr/local" directory.

  3. I am missing something that tells the executable where to find the path of the DLL file to load; this should be something like "-Wl,-rpath,/usr/local/lib" added to the LDDL_FLAGS variable. But I tried that (see file tcl.m4.cygwin) and it didn't work. This can be worked around by doing "export PATH="$PATH:/usr/local/lib" in the terminal window before running tclsh or wish. If anybody knows of a real solution to this problem, I'd like to know.

    Addendum: It appears that Cygwin has no "ldconfig" and no concept of run-time library link directory lists, so the way I have handled it is, in fact, the "proper", or at least recommended, procedure.
  4. Test the operation of the "wish" executable and the DLL libraries by doing the following:
    If you are not running an X server, then in one Cygwin terminal window, do:
    1. Xwin_GL -multiwindow
      (or, "Xwin -multiwindow" if you don't have the GL-enabled X server)
    Leave this running (it can also be backgrounded), and then in a new Cygwin terminal window, do:
    1. export PATH="$PATH:/usr/local/lib"
    2. export DISPLAY=":0.0"
    3. wish
    This should make the default wish top-level window appear on the Windows desktop.
  5. From this point, it is possible to download and compile XCircuit from the source distributions. XCircuit will make use of the compiled Tcl/Tk DLL files and the wish executable. However, note that the "export" commands above need to be entered before XCircuit will launch. They can be added to the top of the shell script "/usr/local/bin/xcircuit".

Last updated: August 5, 2016 at 7:21pm