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 You Start
Before trying to compile Tcl you should do the following things:
-
Evaluate TclPro. The TclPro evaluation
download includes a compiled version of Tcl/Tk in an
easy-to-install package. There are downloads for
Solaris, Linux, HP-UX, IRIX and Windows.
Even if you do not choose to purchase the TclPro tool suite,
you can keep the basic Tcl/Tk installation, which also incorporates
extensions like [incr Tcl], Expect, and TclX.
-
Check for a binary release. Pre-compiled binary releases are
available now for PCs, Macintoshes, and several flavors of UNIX.
Binary releases are much easier to install than source releases.
To find out whether a binary release is available for your
platform, check the
Scriptics Tcl Resource Center.
Also, check in
the FTP directory from which you retrieved the base
distribution.
-
Make sure you have the most recent patch release. Look in the
FTP directory from which you retrieved this distribution to see
if it has been updated with patches. Patch releases fix bugs,
so you should normally use the
latest patch release for the version of Tcl that you want.
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.
- mac Contains Macintosh-specific files and Code Warrior 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.
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++. (Eventually we plan to support
autoconf and the cygwin compiler on Windows.)
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.3.1 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.3.1, wish8.3.1) for Solaris.
Compiling Tcl on UNIX has two steps: configure and make.
In the simplest case you type the following commands to your shell:
cd tcl8.3.1/unix
configure options
make
make test
make install
Configure
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:
-
--prefix=directory
- This flag specifies the installation directory. The default is
/usr/local.
-
--exec-prefix=directory
- 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 the following special
switches in addition to the standard ones:
-
--enable-gcc - If this switch is set, Tcl will configure
itself to use gcc if it is available on your
system. Note: it is not safe to modify the
Makefile to use gcc after configure is run;
if you do this, then information related to
dynamic linking will be incorrect.
-
--enable-threads
- If this switch is set, Tcl will compile
itself with multithreading support.
-
--disable-load
- If this switch is specified then Tcl will
configure itself not to allow dynamic loading,
even if your system appears to support it.
Normally you can leave this switch out and
Tcl will build itself for dynamic loading
if your system supports it.
-
--enable-shared
- If this switch is specified, Tcl will compile
itself as a shared library if it can figure
out how to do that on this platform.
This is now the default.
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.3.1/unix
mkdir solaris
cd solaris
/home/user/src/tcl8.3.1/unix/configure \
--enable-gcc --enable-shared \
--prefix=/usr/local \
--exec-prefix=/usr/local/solaris-sparc
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.3.1/unix
mkdir solaris
cd solaris
/home/user/src/tk8.3.1/unix/configure \
--enable-gcc --enable-shared \
--with-tcl=/home/user/src/tcl8.3.1/unix/solaris \
--prefix=/usr/local \
--exec-prefix=/usr/local/solaris-sparc
Building with Make
What is Make?
After you configure your Makefile,
type "make".
This will create a library archive called libtcl.a
or libtcl.so 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 libtk.so 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
Installation Help Database.
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.
In order to compile Tcl for Windows, you need the following items:
- Tcl 8.3.1 source distribution (or the latest patch release)
- Visual C++ 2.x/4.x/5.x.
Scriptics builds the Windows binary release with Visual C++ 5.0
In the win subdirectory of the source release, you will
find makefile.vc. This is the makefile for the Visual C++
compiler. You should update the paths at the top of the file to
reflect your system configuration. Now you can use make
(or nmake for VC++) to build the tcl libraries and the
tclsh executable.
In order to use the binaries generated by these makefiles, use
make install
to place the Tcl script library files someplace where Tcl can
find them. Tcl looks in one of three places for the library files:
- The path specified in the environment variable "TCL_LIBRARY".
- In the lib/tcl8.3.1 directory under the installation directory
as specified in the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.3.1
- Relative to the directory containing the current .exe.
Tcl will look for a directory "../lib/tcl8.3.1" relative to the
directory containing the currently running .exe.
Note that in order to run tclsh831.exe, you must ensure that tcl831.dll
and tclpip831.dll are on your path, in the system directory, or in the
directory containing tclsh831.exe.
Compiling Tk for windows follows a similar process.
You must compile Tcl before you compile Tk.
If you are compiling an Tcl extension for windows,
please see our guide to
Building Tcl Extensions for Windows.
In order to compile Macintosh Tcl you must have the
following items:
- CodeWarrior Pro 2 or 3
- Mac Tcl 8.3.1 (source)
- More Files 1.4.3
There are two sets of project files included with the package. The ones
we use for the release are for CodeWarrior Pro 3, and are not compatible
with CodeWarrior Gold release 11 and earlier. We have included the files
for earlier versions of CodeWarrior in the folder tcl8.3.1:mac:CW11 Projects,
but they are unsupported, and a little out of date.
As of Tcl8.0p2, the code will also build under CW Pro 2. The only
change that needs to be made is that float.mac.c should be replaced by
float.c in the MacTcl MSL project file.
However, there seems to be a bug in the CFM68K Linker in CW Pro 2,
which renders the CFM68K Version under CW Pro 2 very unstable. I am
working with MetroWerks to resolve this issue. The PPC version is
fine, as is the Traditional 68K Shell. But if you need to use the
CFM68K, then you must stay with CW Pro 1 for now.
The project files included with the Mac Tcl source should work
fine. The only thing you may need to update are the access paths.
Unfortunantly, it's somewhat common for the project files to become
slightly corrupted. The most common problem is that the "Prefix file"
found in the "C/C++ Preference" panel is incorrect. This should be
set to MW_TclHeaderPPC, MW_TclHeader68K or MW_TclHeaderCFM68K.
To build the fat version of TclShell, open the project file "TclShells.",
select the "TclShell" target, and build. All of the associated binaries will
be built automoatically. There are also targets for building static 68K
and Power PC builds, for building a CFM 68K build, and for building a
shared library Power PC only build.
Special notes:
- There is a small bug in More Files 1.4.3. Also you should not use
MoreFiles 1.4.4 - 1.4.6. Look in the file named morefiles.doc for
more details.
- You may not have the libmoto library which will cause a compile
error. You don't REALLY need it - it can be removed. Look at the
file libmoto.doc for more details.
- Check out the file bugs.doc for information about known bugs.
Top of page
Developer Home
| Scriptics
| Getting Started
| Tcl Advocacy
| Software Resources
| Documents
| Services
| Community
Search
| Site Map
| Feedback
| Contact Us
| webmaster@scriptics.com
Increase page width
© 1998-2000 Scriptics Corporation. All rights reserved.
Legal Notice |
Privacy Statement
Last modified: February 10, 2000