Updated 2013-07-22 07:13:59 by oehhar

Purpose: accumulate notes about building, testing and installing Tcl from its source distribution.

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 derived, Windows, and MacOS. [Add something here about platforms other than these 3 do].

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

[Note that 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 [where you replace these flags with the real ones you need]
  • execute make and resolve any errors
  • execute make test and investigate errors. Contact people on http://tcl.sf.net/, news:comp.lang.tcl or http://wiki.tcl.tk/ for help.
  • execute make install and resolve any errors

With newer versions of bash (>3.0) 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.

Note that 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 has /usr/ucb in their path, but do not have a C compiler in their environment.

The path of least resistance for building and testing Tcl on Windows is somewhat different, at least if you have VC++6. (It is rumored that a combination of MinGW and Cygwin make also works, but I've not tried it.) On Windows with VC++6, the steps are:

  • download a copy of the Tcl zip or source file
  • create a directory where you plan on compiling the code
  • 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 the win directory
  • edit the first few lines of Makefile.vc to point correctly to the VC++6 installation and to where you want Tcl to be installed.
  • Run vcvars32.bat if you don't have the VC++6 environment set up in your startup.
  • do nmake -f Makefile.vc all tcltest and investigate errors.
  • do nmake -f Makefile.vc test and investigate errors. Contact people on http://tcl.sf.net/, news:comp.lang.tcl or http://wiki.tcl.tk/ for help.
  • do nmake -f Makefile.vc install and resolve any errors.

./configure adds very little value on Windows systems, which are fairly homogeneous.

If you have gcc 3.3 or newer, look here on how to Build Tcl with profile based optimization.

  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.

Joe English advised on clt to use a site configure configuration file [1].

If one adds a file /usr/local/share/config.site with the contents:
# /usr/local/share/config.site 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)
true

(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/config.site

The files will be installed as follows:

  • /usr/local/lib: tcl scripts: tcl8/, tcl8.6/
  • /usr/local/lib64: shared libraries & compile files: libtcl8.6.so, libtclstub8.6.so, pkconfig/, tclConfig.sh, tclooConfig.sh

If Itcl is installed (as 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/libtcl.8.6.so

/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 libtcl8.6.so
-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 libtk8.6.so
-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 tclConfig.sh
-rw-r--r--. 1 root root     786  8. Okt 13:40 tclooConfig.sh
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 tkConfig.sh


  Specify test options with Makefile.vc and MSVC++6

HaO 2013-03-27: One may use :
nmake -f Makefile.vc test OPTS=threads TESTFLAGS="-verbose \"body start error\" -file event.test"

to specify flags to the test run. [2]

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