Tcl HomeTcl Home Hosted by

Google SiteSearch

Source Organization | Installed Files | Compiling on UNIX | Compiling on Windows | Compiling on Macintosh

This page provides a "how to" guide for compiling Tcl from a source distribution. Tcl has been ported to a wide variety of platforms, and compilation has been made easier through GNU autoconf on UNIX.

Before trying to compile Tcl, you may wish to check if a binary distribution is already available for your platform.

Source Code Organization

Each Tcl component has its source organized into the following structure, which is illustrated in the figure below:

  • doc Contains manual pages in a variety of formats.
  • generic Contains source code that is common for all platforms (.c and .h files)
  • library Contains a library of Tcl scripts used by the component.
  • macosx Contains Macintosh-specific files and XCode project files.
  • tests Contains a test suite.
  • tools Contains a collection of tools used when generating Tcl distributions. (Tcl only.)
  • unix Contains UNIX-specific source code and configure and Makefiles used for building on UNIX (including Mac OS X). You can create subdirectories of the unix directory if you want to build for multiple versions of UNIX.
  • win Contains Windows-specific source code and Makefiles used for compiling with VC++ or mingw (gcc).

Installed Software Organization

When you install Tcl, it ends up in a different organization that supports an installation for multiple operating systems and machine types. You can define architecture-specific subdirectories (e.g., solaris-sparc) that contain programs and binary object files for that platform. The directory structure also supports installation of various Tcl extensions so they can be automatically found by the Tcl shell programs. For example, any subdirectory of the install/lib directory is searched for Tcl script packages, and any shared libraries in the architecture-specific lib directory can be dynamically loaded into the Tcl shells.

After installation, Tcl files are kept in the following structure:

  • doc Contains manual pages in a variety of formats.
  • lib Contains subdirectories for each Tcl package that contain their Tcl script files.
  • lib/tcl8.5 The installed Tcl script library
  • linux-ix86 Contains compiled shells and libraries for Linux.
  • solaris-sparc Contains compiled shells and libraries for Solaris.
  • solaris-sparc/lib Contains runtime libraries (.so files) for Solaris.
  • solaris-sparc/bin Contains executable shells (tclsh8.5, wish8.5) for Solaris.

Configuring and Compiling on UNIX

Compiling Tcl on UNIX has two steps: configure and make. In the simplest case you type the following commands to your shell:

  cd tcl8.5.0/unix
  configure options
  make test
  make install


The configure script tests your system for different compilation and linking options and generates a Makefile. The configure script is created by GNU autoconf. There are two commonly-specified configure options:

This flag specifies the installation directory. The default is /usr/local.
This flag specifies the installation directory for architecture-specific (i.e., binary) files. The default is to install architecture-specific files into the location specified by --prefix. This is typically set to a subdirectory of the main prefix, (e.g., /usr/local/solaris-sparc) for sites that want to maintain binaries for multiple architectures. If you just have a single system type, then you can ignore this option.

Note: be sure to use only absolute path names (those starting with "/") in the --prefix and --exec-prefix options.

To install into the directories /home/user/tcl/bin and /home/user/tcl/lib, for example, you should configure with:

  configure --prefix=/home/user/tcl

Tcl's configure supports several options in addition to the standard ones. Calling configure --help will list them all, but common options are:

If this switch is specified (the default), Tcl will compile itself as a shared library if it can figure out how to do that on this platform. Add =no will create a static build.
If this switch is specified, Tcl will build with debugging symbols.

If you wish to specify a particular compiler, set the CC environment variable before calling configure. You can also specify CFLAGS prior to configure and they will be used during compilation.

Configuring for multiple architectures

Suppose you are building for two platforms, Linux and Solaris, and your installation will be shared by both kinds of hosts. You'll want to use the --exec-prefix configure option to specify different binary installation directories.

There are two ways you can build for multiple platforms. The first way is to build both platforms in the unix subdirectory. First configure and build for one platform. After you install, type make distclean and then configure and build for the second platorm. Be sure that both the configure and build steps are run on the platform for which you are building. For example, don't configure under Solaris and then build under HP-UX.

You can also build the different platforms in different subdirectories of the unix directory. If you do this, then you must name the configure script with a full pathname. For example:

  cd /home/user/src/tcl8.5.0/unix
  mkdir solaris
  cd solaris
  /home/user/src/tcl8.5.0/unix/configure \  
	--prefix=/usr/local \ 

Configuring Tk

When you configure Tk you may need to tell it where Tcl was built with the --with-tcl flag. This is true, for example, if you build Tcl in a subdirectory of unix as just described. To configure Tk:

  cd /home/user/src/tk8.5.0/unix
  mkdir solaris
  cd solaris
  /home/user/src/tk8.5.0/unix/configure \ 
	--with-tcl=/home/user/src/tcl8.5.0/unix/solaris \ 
	--prefix=/usr/local \ 

Building with Make

What is Make?

After you configure your Makefile, type "make". This will create a library archive called libtcl.a or and an interpreter application called tclsh that allows you to type Tcl commands interactively or execute script files. When you build Tk, you create libtk.a or and the wish executable.

Type "make test" to run an exhaustive test suite. In most cases there should not be test failures. The Tk test suite, however, does have some tests that depend on font metrics and the window manger, which can vary across platforms. The README file in the tests subdirectory has documentation about the test suite.

Type "make install" to install Tcl binaries and script files in the directories you specified with --prefix or --exec-prefix during the configure step. You'll need write permission on the installation directories to do this.

If you have trouble compiling Tcl, check out the platforms list. This is an on-line database of porting information. We make no guarantees that this information is accurate, complete, or up-to-date, but you may find it useful. If you get Tcl running on a new configuration, we would be happy to receive new information to add to the database. We're also interested in hearing how to change the configuration setup so that Tcl compiles out of the box on more platforms.

Compiling on Windows

In order to compile Tcl for Windows, you need the following items:

  • Tcl 8.6.14 source distribution (or the latest patch release)
  • MS Visual C++ 6.x or greater.

In the win subdirectory of the source release, you will find This is the makefile for the Visual C++ compiler. You should update the paths at the top of the file as appropriate for your environment.

In order to build the executables, type the following commands in a command shell.

nmake -f INSTALLDIR=path_to_your_install_dir
nmake -f install INSTALLDIR=path_to_your_install_dir

The built files will be named tclsh86t.exe and you may wish to rename them to tclsh.exe.

Compiling Tk for windows follows a similar process. You must compile Tcl before you compile Tk and in addition you must set the variable TCLDIR to the location of your Tcl source directory. Within the win directory in your Tk distribution, type the commands

nmake -f INSTALLDIR=path_to_your_install_dir TCLDIR=path_to_tcl_source
nmake -f install INSTALLDIR=path_to_your_install_dir TCLDIR=path_to_tcl_source

This will produce a wish86t.exe executable and place it within the Tcl installation direcory.

If you are compiling a Tcl extension for windows, please see the TEA reference.

Compiling for Macintosh

Tcl 8.4 was the last version to support Mac Classic (OS <= 9). See the READMEs in the sources for Mac Classic build support. For Mac OS X, use the unix instructions above, with consideration for the following extra options:

Builds the shared libraries as Mac OS X Frameworks.
Target the Aqua windowing system instead of X11 on Mac OS X.