Version 3 of How to start with tcllib

Updated 2001-11-29 13:48:59

Purpose: to discuss how to install and use the tcllib extension.


Crude answer, relevant mostly to versions before 1.0: unpack the source distribution into a directory such as

  $MYDIR

so that there are files such as

  $MYDIR/tcllib/mime/mime.tcl

At the level of Tcl source, you don't use tcllib; you use packages from the tcllib distribution. To use the mime package, for example, you might

  lappend auto_path $MYDIR/tcllib
  package require mime
  # ... Now you can use any of the mime::* proc's.

HOWEVER I LV strongly recommend that, if at all possible, you go ahead and do the configure, etc. mentioned below.


The safest thing to do though is to run the tcllib/configure [make point of detailing which versions of tcllib have configure - versions since 2000 at least] with the appropriate flags, then to run "make install" so that files end up in the location tcl expects to find them, with the proper names, etc.

configure can be invoked with flags pointing to some other directory than where Tcl is installed; point at a $HOME directory for instance. When you do this, then don't forget to make use of the auto_path trick mentioned above.


WARNING! Use Tcl8.2 or later with recent tcllib (certainly 0.8 and higher). There are cases where in particular the code uses the new string functionality that appears in later versions of tcl to dramatically improve performance. This results in locking tcllib currently into newer versions.

There have been discussions about people wanting/needing tcllib to work on older versions of tcl working together to write some forward compatibility procs for tcllib, so that it can be used over a wider range of versions. Alas, this work has not proceeded very quickly.


Steps to installing tcllib - or most other TEA based applications.

The way one does this is this. Perhaps at some point, some derivative of this information might be useful to make available in tcllib and the other TCT managed software distributions.

1. Obtain the tar file that you wish to use.

        I currently recommend to people that they get the latest tcllib tar
        file from either http://tcllib.sf.net/ or
        ftp://ftp.scriptics.com/pub/tcl/nightly-cvs/ .

2. cd into a working directory

3. Untar the downloaded file. What you have as a result is a directory in the current directory called "tcllib". If you see an error, the most likely cause of this error is that the file was downloaded as a text file instead of a binary file. Other possible errors are not having a program that knows how to deal with a gzip'd tar file, lack of disk space, or lack of permissions to write into the disk space.

4. cd tcllib

5. Now a choice needs to be made . Tcl needs to find the modules in a known directory. You have two choices. You can either install things into one of the built in directories of Tcl, or you can add an environment variable or lines to your Tcl code so that Tcl can find the library. What _I_ do is to tell tcllib to install in the same place I tell Tcl to install. For instance, I currently am building Tcl 8.3.3 to install in /usr/tcl83 ; when I build tcllib for that version of tcl, I tell tcllib to install there as well. In my case, I type:

$PWD/configure --prefix=/usr/tcl83

You would use a directory matching the directory you told tcl. If you installed a binary version of tcl, then type info library

and you will get a path back such as:

% info library /usr/tcl83/lib/tcl8.3

In this case, Tcl was configured with a '--prefix=/usr/tcl83' .

6. The result of the configure you just did SHOULD be a Makefile. If not, then you've found a problem on your system; this might be a configure bug, or it might be some problem on your system (for instance, perhaps your system has no compiler or some other required application).

In the case of an error, read through the output to the screen as well as the config.log file and see if the error messages lead you to a solution. It would be useful to search http://tcllib.sf.net/ bug report database to see if you can find previous reports of errors with fixes. If nothing reasonable is determinable or found, then submit a bug report. The form there asks for a lot of info - the more you provide, the more likely the problem can be resolved. At this point, you would cycle back to one of the previous steps and begin again.

7. If the result of the configure was a Makefile, then you should type the name of the make command you use. Often this will be "make" or "gmake". There are other make files for other platforms - I don't know those other platforms, so I don't have instructions for you.

8. In the case of an error, read through the output to the screen and see if the error messages lead you to a solution. It would be useful to search http://tcllib.sf.net/ bug report database to see if you can find previous reports of errors with fixes. If nothing reasonable is determinable or found, then submit a bug report. The form there asks for a lot of info - the more you provide, the more likely the problem can be resolved. At this point, you would cycle back to one of the previous steps and begin again.

9. If the result of the make was successful, then I recommend telling your make to run the target of "test", which runs the tcllib through a test suite. If this results in any indication of warnings or errors, read through the output to the screen and see if the error messages lead you to a solution. It would be useful to search http://tcllib.sf.net/ bug report database to see if you can find previous reports of errors with fixes. If nothing reasonable is determinable or found, then submit a bug report. The form there asks for a lot of info - the more you provide, the more likely the problem can be resolved. At this point, you would cycle back to one of the previous steps and begin again.

10. If the result of the test was successful, then you tell your make command to run the install target. This results in an attempt to create directories and copy files into those directories. During this process, you will likely see warnings about directories already existing - this is an error you can ignore. The result should be a tcllib whose modules are installed appropriately.