Updated 2017-05-15 20:03:46 by dbohdan

dbohdan 2016-12-04: This is a step-by-step guide on how to build native Tcl/Tk binaries for Windows on Windows. I found it the most convenient to do with MSYS2. The result of following this guide will be a complete Tcl/Tk installation that is portable from one Windows machine to another. The instructions have been tested with Tcl 8.6.6.

1. Install MSYS2 by following the instructions on its webpage. Prefer the 64-bit version if you have 64-bit Windows. You will be able to build 32-bit and 64-bit binaries from the 64-bit version.

2. Start "MSYS2 MingGW 32-bit" from the "MSYS2 64bit" folder in the Start menu.

3. Install the build dependencies by running the following command in the shell:
pacman -Syuu make mingw-w64-i686-gcc tar wget

4. Download and extract the latest source code release of Tcl. The GitHub mirror is convenient for this because it does not require authentication. Build and install Tcl.
cd ~
wget -O tcl-release.tar.gz https://github.com/tcltk/tcl/archive/release.tar.gz
tar xvf tcl-release.tar.gz
cd tcl-release/win/
./configure --enable-threads --prefix=/c/tcltk/
make
make install

5. (Optional) Build and install Tk.
$ cd ~
$ wget -O tk-release.tar.gz https://github.com/tcltk/tk/archive/release.tar.gz
$ tar xvf tk-release.tar.gz
$ cd tk-release/win/
$ ./configure --prefix=/c/tcltk/ --with-tcl=../../tcl-release/win/
$ make
$ make install

6. (Optional) Install Tcllib.
cd ~
wget -O tcllib-release.tar.gz https://github.com/tcltk/tcllib/archive/release.tar.gz
tar xvf tcllib-release.tar.gz
cd tcllib-release/
./configure --prefix=/c/tcltk/
make install

You will find your Tcl/Tk installation in C:\tcltk\.

To build a 64-bit version run "MSYS2 MingGW 64-bit" instead of "MSYS2 MingGW 32-bit" in step 2, install mingw-w64-x86_64-gcc instead of mingw-w64-i686-gcc in step 3 and configure Tcl and Tk with the option --enable-64bit in steps 4-5.