critcl_howto_install - How To Install CriTcl
Be welcome to the C Runtime In Tcl (short: CriTcl), a system for embedding and using C code from within Tcl scripts.
CriTcl is installed in four major steps:
Follow the instructions on How To Get The CriTcl Sources
It is now possible to follow the instructions on How To Use CriTcl.
This major step breaks down into three minor steps:
Install A Working C Compiler and development environment.
While CriTcl requires a working C compiler to both install itself, and to process CriTcl-based packages installing such is very much out of scope for this document.
Please follow the instructions for the platform and system CriTcl is to be installed on.
The important pieces of information are this:
The path to the directory containing the C compiler binary has to be listed in the environment variable PATH, for CriTcl to find it.
On Windows(tm) the environment variable LIB has to be present and contain the paths of the directories holding Microsoft's libraries. The standard CriTcl configuration for this platform searches these paths to fine-tune its settings based on available libraries and compiler version.
Links of interest:
That a working installation of CriTcl will require a working installation of Tcl should be obvious.
Installing Tcl however is out of scope here, same as for installing a working C compiler.
There are too many options, starting from building it from scratch, installing what is provided by the platform's package manager (zypper, yum, apt-get, and more), to using some vendor's distribution.
A single piece of advice however.
While CriTcl currently supports running on Tcl 8.4 and higher, and the creation of packages for the same, the last release for this version was in 2013 (9 years ago at the time of writing). Similarly, the last release for Tcl 8.5 was in 2016 (6 years ago). Both are official end of life.
Given this I recommend to install and use Tcl 8.6.
The implementation of CriTcl uses and depends on
cmdline
Depending on how Tcl was installed this package may be available already without action, or not. Invoke the command
echo 'puts [package require cmdline]' | tclsh
to check if the package is present or not. If it is present then its version number will be printed, else the error message can't find package cmdline or similar.
If it is not present install the package as per the instructions for the chosen Tcl installation.
Note, the package cmdline may not exist as its own installable package. In such a case check if the chosen Tcl installation provides a tcllib package and install that. This should install all the packages in the Tcllib bundle, including cmdline.
As a last fallback, go to Tclib and follow the instructions to install the bundle from scratch.
Note that this step has different instructions dependent on the platform CriTcl is to be installed on. In other words, only one of the sub sections applies, the other can be ignored.
This section offers instructions for installing CriTcl on various kinds of Unix and Unix-related systems, i.e. Linux, the various BSDs, etc. It especially covers Mac OS X as well.
Use the instructions in section Install On Windows when installing on a Windows platform and not using a unix-like environment as provided by tools like MinGW, CygWin, Git For Windows, WSL, etc.
Change the working directory to the top level directory of the CriTcl checkout obtained by following the instructions of How To Get The CriTcl Sources.
Verify that the file "build.tcl" is marked executable. Make it executable if it is not.
Invoke
./build.tcl install
to perform the installation.
Attention This command uses default locations for the placement of the critcl application, the various packages, and header files.
Invoke
./build.tcl dirs
to see the chosens paths before actually performing the installation.
Use the options listed below to change the paths used for installation as desired. This is the same method as with configure based packages.
These options are especially necessary in all environments not using the semi-standard "bin", "lib", "include" locations from configure.
As an example of such environments, Ubuntu (and possibly Debian) expect Tcl packages to be installed into the "/usr/share/tcltk" directory, therefore requiring the use of
--lib-dir /usr/share/tcltk
for proper installation.
Note that this guide neither covers the details of the install method, nor does it cover any of the other methods available through the build.tcl tool of CriTcl. These can be found in the CriTcl build.tcl Tool Reference.
This section offers instructions for installing CriTcl on a Windows (tm) host. Note that environments as provided by tools like MinGW, CygWin, Git For Windows, WSL, etc. are classed as Unix-like, and the instructions in section Install On Unix apply.
In a DOS box, change the working directory to the top level directory of the CriTcl checkout obtained by following the instructions of How To Get The CriTcl Sources.
In the same DOS box, invoke
tclsh.exe ./build.tcl install
to perform the installation.
Attention This command uses default locations for the placement of the critcl application, the various packages, and header files.
Invoke
tclsh.exe ./build.tcl dirs
to see the chosens paths before actually performing the installation.
Use the options listed below to change the paths used for installation as desired. This is the same method as with configure based packages.
Attention! The current installer does not put an extension on the critcl application. This forces users to either explicitly choose the tclsh to run the application, or manually rename the installed file to "critcl.tcl". The latter assumes that an association for ".tcl" is available, to either tclsh, or wish.
Note that this guide neither covers the details of the install method, nor does it cover any of the other methods available through the build.tcl tool of CriTcl. These can be found in the CriTcl build.tcl Tool Reference.
Installing CriTcl contains an implicit test of its functionality.
One of its operation modes uses the MD5 hash internally to generate unique ids for sources, as a means of detecting changes. To make generation of such hashes fast a CriTcl-based package for MD5 is installed as part of the main installation process.
In other words, after installing the core packages of CriTcl this partial installation is used to build the rest.
This is possible because building a package from CriTcl-based sources is the operation mode not using MD5, therefore there is no circular dependency.
For our purposes this however is also a self-test of the system, verifying that the core of CriTcl works, as well as the C compiler.
For additional testing simply move on to section The First Package of the guide on How To Use CriTcl.
Jean Claude Wippler, Steve Landers, Andreas Kupries
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report them at https://github.com/andreas-kupries/critcl/issues. Ideas for enhancements you may have for either package, application, and/or the documentation are also very welcome and should be reported at https://github.com/andreas-kupries/critcl/issues as well.
C code, Embedded C Code, calling C code from Tcl, code generator, compile & run, compiler, dynamic code generation, dynamic compilation, generate package, linker, on demand compilation, on-the-fly compilation
Glueing/Embedded C code
Copyright © Jean-Claude Wippler
Copyright © Steve Landers
Copyright © 2011-2024 Andreas Kupries