Mo Dejong 10-12-2005
This page describes how to build Tcl/Tk under Windows using the Msys and Mingw packages. Mingw is a gcc port for Windows that can be used to build native Win32 applications and dlls. Msys is a bash shell ported to Windows that is used to run Tcl's configure script. This page does not describe how to build Tcl/Tk with VC++, although that build environment is also supported. It may possible to build Tcl/Tk with other compilers like the Borland or Cygwin, but these tools are not well supported and will require some effort to get everything working.
Building Tcl/Tk 8.4.16, the current stable release.
First (Downloads):
GJW The aforementioned MinGW is extremely old and will not build Tcl 8.6. Try installing from http://www.mingw.org/ instead.
Second (Unzip):
Third (Build Tcl):
Fourth (Build Tk):
NOTE: At this point everything is installed and should be working. You could delete /build and /src if you wanted to. You will find it all in /opt/tcl (C:\msys\opt\tcl). Run Tcl from the msys shell by starting the tclsh84 shell found in /opt/tcl/bin. Run Tk from the msys shell by starting the wish84 shell found in /opt/tcl/bin.
RS It's also useful to copy tcl84.exe to tclsh.exe, and add /opt/tcl/bin to the msys PATH, so that you can run scripts directly when their first line is the famous
#!/usr/bin/env tclsh
See also
Note: ensure that your msys.bat file contains a set PATH= at the top or you will get coredumps.
RS 2007-10-11: This advice leads, on my W95 box, to msys dying very soon after startup. Trying to find another way...
DKF: I never needed to do that, but then I use XP. (It's much more important to make sure that you install things in a directory without spaces in the name; a lot of the build process is very fragile if you don't follow that...)
See Windows 95 for RS's adventures in building 8.5b1 on that unsupported platform...
LV Anyone tried this on Vista? Also, have you tried updating to newer versions of the compiler, etc. ? Just curious how robust of an environment mingw is. :Working fine under Windows 7 beta, so vista likely has no problems. Ian S.
edit that path typo in third step. I made the tclsh bin under XP inside VMWARE6.03 ACE from tcl856-src. salut
SV (2009-08-10) I would like to add that succesful build of tcl 8.6b1.1 (from cvs) is possible with current mingw (gcc 4.4.0). After some tinkering with content of msys_mingw8.zip and reading some pages on MinGW site it was quite easy.
Here follows what I did. Note: my platform is xp sp2 on Linux kvm.
1. Abandon use of MinGW-5.1.4.exe automatic installer, it's broken.
2. Download from http://sourceforge.net/projects/mingw/files/
mingwrt-3.15.2-mingw32-dev.tar.gz mingwrt-3.15.2-mingw32-dll.tar.gz mpfr-2.4.1-mingw32-dll.tar.gz gmp-4.2.4-mingw32-dll.tar.gz libiconv-1.13-mingw32-dll-2.tar.gz pthreads-w32-2.8.0-mingw32-dll.tar.gz gcc-core-4.4.0-mingw32-dll.tar.gz gcc-core-4.4.0-mingw32-bin.tar.gz binutils-2.19.1-mingw32-bin.tar.gz w32api-3.13-mingw32-dev.tar.gz (this one was corrupted on a few sourceforge mirrors)
Unpack all with paths in C:\MinGW. Directory tree should look like this on first level:
C:\MinGW |-- bin |-- doc |-- include |-- info |-- lib |-- libexec |-- man |-- mingw32 `-- share
There is conflict on libiberty.a between gcc-core-4.4.0-mingw32-dll.tar.gz and binutils-2.19.1-mingw32-bin.tar.gz, keep that from gcc-core.
3. Add 'C:\MinGW\bin' to system PATH variable.
4. Download MSYS-1.0.11.exe, run it and answer questions. (However after all I have to manually correct fstab in msys's /etc directory to (note the double backslashes):
C:\\MinGW /mingw
5. Follow 'only' instruction about unpacking tcl and tk from Mo Dejong on top of this page.
6. Then in msys's shell you could run something like this script below or proceed compiling manually.
#!/bin/sh mkdir -p /src mkdir -p /opt/tcl mkdir -p /build/tcl mkdir -p /build/tk [ -e /src/tcl ] && { cd /build/tcl /src/tcl/win/configure --prefix=/opt/tcl --enable-threads && make && make install && { [ -e /src/tk ] && { cd /build/tk /src/tk/win/configure --prefix=/opt/tcl --enable-threads --with-tcl=/build/tcl \ && make && make install } } }
Note that you can install them to an absolute path like
$ win/configure --prefix=/c/pathname
And that you can install Tk/Tcl to their "default" location by using
tcl: $ win/configure --prefix=/mingw tk: $ win/configure --prefix=/mingw --with-tcl=/mingw/lib
RZ 20110220
Things seem to have improved. I installed msys/mingw with the default installer http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/mingw-get-inst-20110211/mingw-get-inst-20110211.exe and selected also g++, msys, and tools.
To test it I got kbs.tcl from http://sourceforge.net/projects/kbskit/ and compiled Tcl, Tk and kbskit with:
./kbs.tcl -r install kbskit8.5
bll 2016-1-20 configure's standard test for checking whether make sets MAKE fails. mingw32-make/bash is not processing the echo statement in the makefile properly. I am not familiar with MSys; only ran across it recently.
$ export MAKE=mingw32-make $ cat conftest.make all: @echo 'ac_maketemp="$(MAKE)"' $ $MAKE -f conftest.make ac_maketemp=\mingw32-make"
DRB - 2018-08-27 11:17:16
Can this be updated for https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe/download%|%MinGW64%|% ?
DRB - 2018-08-27 11:54:32
Specifically, I installed MSYS2, did the updates, then
$ pacman -S mingw-w64-x86_64-gcc $ /src/tcl8.6.8/win/configure --prefix=/opt/tcl $ make lots of things that look like sucessful compilation... then... gcc -c -O2 -fomit-frame-pointer -DUNICODE -D_UNICODE -D_ATL_XP_TARGETING -Wall -Wdeclaration-after-statement -I"C:/msys64/src/tcl8.6.8/compat/zlib" -I"C:/msys64/src/tcl8.6.8/generic" -DTCL_TOMMATH -DMP_PREC=4 -I"C:/msys64/src/tcl8.6.8/libtommath" -I"C:/msys64/src/tcl8.6.8/win" -pipe -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DSTDC_HEADERS=1 -DTCL_THREADS=1 -DUSE_THREAD_ALLOC=1 -DTCL_CFGVAL_ENCODING=\"cp1252\" -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DMODULE_SCOPE=extern -DTCL_CFG_DO64BIT=1 -DHAVE_NO_SEH=1 -DHAVE_CAST_TO_UNION=1 -DHAVE_ZLIB=1 -DHAVE_INTPTR_T=1 -DHAVE_UINTPTR_T=1 -DHAVE_INTRIN_H=1 -DHAVE_WSPIAPI_H=1 -DNDEBUG=1 -DTCL_CFG_OPTIMIZED=1 -DBUILD_tcl "C:/msys64/src/tcl8.6.8/win/tclWinTime.c" -o tclWinTime.o windres -o tcl.res.o --include "C:/msys64/src/tcl8.6.8/generic" --include "C:/msys64/src/tcl8.6.8/win" "C:/msys64/src/tcl8.6.8/win/tcl.rc" gcc -shared -o tcl86.dll -pipe -static-libgcc -municode -Wl,--out-implib,libtcl86.a regcomp.o regexec.o regfree.o regerror.o tclAlloc.o tclAssembly.o tclAsync.o tclBasic.o tclBinary.o tclCkalloc.o tclClock.o tclCmdAH.o tclCmdIL.o tclCmdMZ.o tclCompCmds.o tclCompCmdsGR.o tclCompCmdsSZ.o tclCompExpr.o tclCompile.o tclConfig.o tclDate.o tclDictObj.o tclDisassemble.o tclEncoding.o tclEnsemble.o tclEnv.o tclEvent.o tclExecute.o tclFCmd.o tclFileName.o tclGet.o tclHash.o tclHistory.o tclIndexObj.o tclInterp.o tclIO.o tclIOCmd.o tclIOGT.o tclIORChan.o tclIORTrans.o tclIOSock.o tclIOUtil.o tclLink.o tclLiteral.o tclListObj.o tclLoad.o tclMain.o tclMain2.o tclNamesp.o tclNotify.o tclOO.o tclOOBasic.o tclOOCall.o tclOODefineCmds.o tclOOInfo.o tclOOMethod.o tclOOStubInit.o tclObj.o tclOptimize.o tclPanic.o tclParse.o tclPathObj.o tclPipe.o tclPkg.o tclPkgConfig.o tclPosixStr.o tclPreserve.o tclProc.o tclRegexp.o tclResolve.o tclResult.o tclScan.o tclStringObj.o tclStrToD.o tclStubInit.o tclThread.o tclThreadAlloc.o tclThreadJoin.o tclThreadStorage.o tclTimer.o tclTomMathInterface.o tclTrace.o tclUtf.o tclUtil.o tclVar.o tclZlib.o bncore.o bn_reverse.o bn_fast_s_mp_mul_digs.o bn_fast_s_mp_sqr.o bn_mp_add.o bn_mp_add_d.o bn_mp_and.o bn_mp_clamp.o bn_mp_clear.o bn_mp_clear_multi.o bn_mp_cmp.o bn_mp_cmp_d.o bn_mp_cmp_mag.o bn_mp_cnt_lsb.o bn_mp_copy.o bn_mp_count_bits.o bn_mp_div.o bn_mp_div_d.o bn_mp_div_2.o bn_mp_div_2d.o bn_mp_div_3.o bn_mp_exch.o bn_mp_expt_d.o bn_mp_grow.o bn_mp_init.o bn_mp_init_copy.o bn_mp_init_multi.o bn_mp_init_set.o bn_mp_init_set_int.o bn_mp_init_size.o bn_mp_karatsuba_mul.o bn_mp_karatsuba_sqr.o bn_mp_lshd.o bn_mp_mod.o bn_mp_mod_2d.o bn_mp_mul.o bn_mp_mul_2.o bn_mp_mul_2d.o bn_mp_mul_d.o bn_mp_neg.o bn_mp_or.o bn_mp_radix_size.o bn_mp_radix_smap.o bn_mp_read_radix.o bn_mp_rshd.o bn_mp_set.o bn_mp_set_int.o bn_mp_shrink.o bn_mp_sqr.o bn_mp_sqrt.o bn_mp_sub.o bn_mp_sub_d.o bn_mp_to_unsigned_bin.o bn_mp_to_unsigned_bin_n.o bn_mp_toom_mul.o bn_mp_toom_sqr.o bn_mp_toradix_n.o bn_mp_unsigned_bin_size.o bn_mp_xor.o bn_mp_zero.o bn_s_mp_add.o bn_s_mp_mul_digs.o bn_s_mp_sqr.o bn_s_mp_sub.o tclWin32Dll.o tclWinChan.o tclWinConsole.o tclWinSerial.o tclWinError.o tclWinFCmd.o tclWinFile.o tclWinInit.o tclWinLoad.o tclWinNotify.o tclWinPipe.o tclWinSock.o tclWinThrd.o tclWinTime.o tcl.res.o -lnetapi32 -lkernel32 -luser32 -ladvapi32 -luserenv -lws2_32 C:/msys64/src/tcl8.6.8/compat/zlib/win32/zdll.lib C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tclZlib.o:tclZlib.c:(.text+0x41): undefined reference to `inflateEnd' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tclZlib.o:tclZlib.c:(.text+0xc1): undefined reference to `deflateEnd' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tclZlib.o:tclZlib.c:(.text+0x3b3): undefined reference to `zError' C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: tclZlib.o:tclZlib.c:(.text+0xd30): undefined reference to `deflate' ... lots more missing references
ray2501 2018-08-27
Try --enable-64bit for zlib when using MSYS2 to build 64bit version. For example, /src/tcl8.6.8/win/configure --prefix=/opt/tcl --enable-64bit --enable-threads
DRB - 2018-08-30 17:15:03
Thanks! I get a tclsh86.exe and wish86.exe that make and make install and work fine when launched from MSYS2's console. However, when I double click on wish86.exe in the regular folder view of Windows 7, I get the error "The application was unable to start correctly (0xc000007b). Click OK to close the application." Is there another step after make install or have I misconfigured the compilation?
bll 2018-8-30:
For my production release with 8.6.8, I do:
export CFLAGS=-m64 make distclean ./configure --prefix=/opt/tcl --enable-64bit --with-encoding=utf-8 make install
Similarly for Tk.
If the make distclean fails, run the configure, then run make distclean again.
For a 32-bit build, I use -m32. And for 32-bit Tk, I edit the Makefile and add -lmscvr100 to the LIBS= line.
DRB - 2018-09-01 14:22:25
Thanks again! That makes a working Tcl/Tk! If anyone would like to poke at this binary it resides at my shell.