Cross-Compiling Tcl/Tk 8.3.2 For WinNT Using Mingw

Beginning with release 8.3.2, Tcl/Tk support building both static libraries and DLL for Windows98/NT using the various GCC cross-compilers. This application note describes how to compile Tcl/Tk 8.3.2 for Windows98/NT using the Mingw cross-compiler.

Getting The Compiler

Instructions for obtaining and building the Mingw cross-compiler on a RedHat 6.0 Linux host can be found at the following places:

The following sites contain lots of useful information, including lots of additional links. But they do not contain specific instructions on how to compile Mingw as a cross-compiler.

If you want to use the Cygwin cross-compiler (which with the -mno-cygwin switch will accomplish about the same thing as Mingw) there are instructions at

This note will assume you have installed Mingw (not Cygwin) in accordances with the instructions found at

Download and Unwrap The Source Distribution

Tcl/Tk 8.3.2 sources are available from Ajuba Solutions at this web address:

Download both the Tcl and the Tk archives and unpack them in parallel directories. The sequel will assume that the source trees are unpacked into ~/tcltk/tcl8.3.2 and ~/tcltk/tk8.3.2 respectively.

Building Tcl

We will build in a subdirectory of the win subdirectory of the source tree.

mkdir ~/tcltk/tcl8.3.2/win/bld
cd ~/tcltk/tcl8.3.2/win/bld

There is file that is misplaced in the Tcl8.3.2 distribution. We have to move it to the correct place before continuing.

ln ../../tools/tcl.hpj ..

Now we are ready to run configure. Notice that the --host= option is used to specify the platform on which the result of compilation will run. This is somewhat counter-intuitive, but it is correct.

../configure --enable-gcc --host=i386-mingw32

The example above will build Tcl using DLLs. If you would rather have static libraries, add the --disable-shared switch. Like this:

../configure --enable-gcc --host=i386-mingw32 --disable-shared

Either way, the Makefile that this script generates contains one minor problem that prevents it from working with Mingw. We need to specify an additional library for the final link. So after running configure, manually edit the resulting Makefile as follows:

** Makefile.orig       Sat Aug 12 16:28:01 2000
--- Makefile    Sat Aug 12 16:27:28 2000
*** 175,181 ****
  VER           = 83
  DOTVER        = 8.3
! LIBS          = 
  RMDIR         = rm -rf
  MKDIR         = mkdir -p
--- 175,181 ----
  VER           = 83
  DOTVER        = 8.3
! LIBS          = -lmsvcrt
  RMDIR         = rm -rf
  MKDIR         = mkdir -p

In words, you want to find the line in the Makefile that specifies the libraries to link against and add the -lmsvcrt library to this set. I believe the Cygwin compiler automatically links against msvcrt. But Mingw links against crtdll unless you specify msvcrt explicitly. Tcl/Tk requires msvcrt.

You will have to repeat this edit whenever you run configure.

Finally, type make to build Tcl.


Building Tk

Tk is built the almost the same way as Tcl. The main differences are that Tk does not have any of the configuration problems that Tcl has. You do not have to make any corrections. Just type "configure" and "make". Like this:

cd ~/tcltk/tk8.3.2/win
mkdir bld
cd bld
../configure --enable-gcc --host=i386-mingw32 \