To build and test Tcl

To build and test Tcl, on Unix-like systems, follow the steps detailed below.

Tcl is frequently obtained by getting the C source code and compiling it. Tcl comes with generic code plus modules specifically designed to compile on Unix, Windows, and MacOS, and other platforms.

See Also

How to Compile Tcl
The official guide to compiling Tcl
Installing Tcl
How to build and install Tcl on various platforms
Build Tcl with profile based optimization
For GCC 3.3 or newer


The steps one takes to build a fresh copy of Tcl are frequently something like:

  • Download a copy of the Tcl source zip or tar file.
  • Create a directory where you plan on compiling the code.
  • Extract the source code (unzip/tar/whatever).
  • Determine where you want to install the binaries.
  • cd into the tcl top level directory.
  • Read the README file (and possibly the ChangeLog and changes files).
  • cd into either the unix, win, mac, or macosx directory.
  • If you are on Unix, make certain that you know what C compiler you wish to use to build Tcl, Tk, etc. The same compiler should be used during the configure and build stage across pieces. You may need to set the CC environment variable, etc. to get the right compiler and flags included.
  • Execute ./configure --help to determine what flags are available to you on your platform and resolve any errors. This step is non-trivial to complete successfully on at least the Windows and MacOS platforms. Perhaps someone will add in a reference here regaling us with their horror stories, or even better, with steps that someone could take to be successful at the work.
  • Execute ./configure --prefix=/your/install/directory --The --Appropriate --Flags --For --Your --Site.
  • Execute make and resolve any errors.
  • Execute make test and investigate errors. get help when necessary to complete the task.
  • Developers may wish to run make valgrind to look for memory issues. See How to debug memory faults in Tcl and extensions for more information.
  • Execute make install and resolve any errors.


Unix users report problems on a regular basis on some platforms and with certain combinations of events. For instance AIX and HP/UX users, I believe, often have problems when using older versions of compilers, or Tcl, etc. Solaris users report configure problems if their $PATH includes /usr/ucb but their environment does not include a C compiler.


configure has a number of flags from which one can choose.

--with-tcl=DIRSpecifies the directory containing the Tcl binaries and Tcl's platform-dependent configuration information. By default the Tcl directory is assumed to be in the location given by (a) above.
--enable-threadsIf this switch is set, Tcl will compile itself with multithreading support.
--enable-sharedIf this switch is specified, Tk will compile itself as a shared library if it can figure out how to do that on this platform. This is the default on platforms where we know how to build shared libraries.
--disable-sharedIf this switch is specified, Tk will compile itself as a static library.
--enable-symbolsBuild with debugging symbols By default standard debugging symbols are used. Specify mem to also include TCL_MEM_DEBUG memory debugging (i.e., to create the memory command), compile for bytecode debugging (see tcl_traceExec), or all to enable all debugging features.
--disable-symbolsBuild without debugging symbols.
--enable-64bitenable 64bit support (where applicable).
--disable-64bitdisable 64bit support (where applicable).
--enable-64bit-visenable 64bit Sparc VIS support.
--disable-64bit-visdisable 64bit Sparc VIS support.
--enable-man-symlinksUse symlinks for linking the manpages that should be reachable under several names.
--enable-man-compression=PROGCompress the manpages using PROG.

Mac OS X only (ignored on other platforms):

--enable-frameworkpackage Tk as a framework.
--disable-corefoundationdisable use of CoreFoundation API.
--enable-aquause Aqua windowingsystem rather than X11, requires --enable-corefoundation with tcl & tk.
Note: by default gcc will be used if it can be located on the PATH. if you want to use cc instead of gcc, set the CC environment variable to "cc" before running configure. It is not safe to change the Makefile to use gcc after configure is run.
Note: be sure to use only absolute path names (those starting with "/") in the --prefix and --exec-prefix options.

Configure Errors

With newer versions of bash (>3.0) and older versions of Tcl, or with Tcl extensions based on TEA, ./configure might fail with an error resembling:

configure might give an error resembling:

./configure: line 7624: syntax error near unexpected token `)'

Refer to bash for the cause and solution of this problem.


To pass arguments to test via make:

make test TESTFLAGS="-file unixInit.test -match unixInit-3.2"


  Build on 64 bit dual bitesize Linux (CentOS 6)

HaO 2012-05-04 configure --enable-64bit was installing shared library in /usr/local/lib and not /usr/local/lib64, where it would be in the library path.

library in lib and not in lib64 when installing tcl8.6 on CentOS 6 64bit , comp.lang.tcl, 2012-05-03, Joe English suggested using an autoconf site defaults file.

For example, /usr/local/share/ might contain:

# /usr/local/share/ for platforms that prefer
# the directory /usr/local/lib64 over /usr/local/lib.
test "$libdir" = '${exec_prefix}/lib' && libdir='${exec_prefix}/lib64'
# to not stop configure if test fails (sqlite and threads in bundled tcl8.6b3)

HaO 2012-10-08: I have added true, as configure stopped with tcl8.6b3 bundled package sqlite as exec_prefix was not defined at all and the test returned 1 and stopped the configure script. Sqlite anyway used already lib64

The following line will be printed if configure --enable-64bit is executed:

configure: loading site script /usr/local/share/

The files will be installed as follows:

tcl scripts: tcl8/, tcl8.6/
shared libraries & compile files:,, pkconfig/,,

If Itcl is installed (as a binary extension), scripts and shared libraries go to /usr/local/lib64/itcl4.0b7. This first felt irritating but is necessary, as Tcl-only extensions may be shared between 32 and 64 bit, but shared libraries not.

The Tcl auto_path is:

$ /usr/local/bin/tclsh8.6
% set auto_path
/usr/local/lib/tcl8.6 /usr/local/lib /usr/local/lib64

which feels strange to me. IMHO, the lib64 should be before lib. This is also like that in the Makefile.

It was still necessary to put a link in /usr/lib64 that linked packages will find the library (ex: Rivet):

# cd /usr/lib64
# ln -s /usr/local/lib64/

/usr/local/bin/tclsh8.6 does not require this link.

Here is a file list of a freshly compiled tcl/tk8.6b3 on CentOS6.3 64 bit of the (quite empty) folder lib:

drwxr-xr-x. 5 root root 4096  8. Okt 13:40 tcl8
drwxr-xr-x. 6 root root 4096  8. Okt 13:40 tcl8.6
drwxr-xr-x. 6 root root 4096  8. Okt 13:39 tk8.6

and the lib64 folder:

drwxr-xr-x. 2 root root    4096  8. Okt 13:41 itcl4.0b8
-r-xr-xr-x. 1 root root 1715711  8. Okt 13:40
-rwxr-xr-x. 1 root root    8028  8. Okt 13:40 libtclstub8.6.a
-r-xr-xr-x. 1 root root 1539775  8. Okt 13:39
-rwxr-xr-x. 1 root root    5472  8. Okt 13:39 libtkstub8.6.a
drwxr-xr-x. 2 root root    4096  8. Okt 13:40 pkgconfig
drwxr-xr-x. 2 root root    4096  8. Okt 13:41 sqlite3.7.14
drwxr-xr-x. 3 root root    4096  8. Okt 13:41 tcl8
-rw-r--r--. 1 root root    7597  8. Okt 13:40
-rw-r--r--. 1 root root     786  8. Okt 13:40
drwxr-xr-x. 2 root root    4096  8. Okt 13:41 tdbc1.0b17
drwxr-xr-x. 2 root root    4096  8. Okt 13:41 thread2.7b1
drwxr-xr-x. 2 root root    4096  8. Okt 13:39 tk8.6
-rw-r--r--. 1 root root    3977  8. Okt 13:39

  Specify test options with and MSVC++6

HaO 2013-03-27:

One may use :

nmake -f test OPTS=threads TESTFLAGS="-verbose \"body start error\" -file event.test"

to specify flags to the test run. [L1 ]

The testflags are passed as parameters to the tcltest.tcl script.

  Specify test options with Unix

HaO 2013-05-29:

One may use :

make test TESTFLAGS="-verbose bst -file event.test" 2>&1 | tee testlog_tcl-trunk.txt

To specify flags to the test run. [L2 ]

The testflags are passed as parameters to the tcltest.tcl script.