Version 6 of Critcl FAQ

Updated 2006-06-09 18:40:46

It is not clear, after reading Critcl pages, exactly what files have to be installed on a Windows machine to use Critcl. Does one have to install the critcl source code and then some other piece(s)?

June 2002 - Yes, you need critcl installed as a normal Tcl package (i.e. so "package require critcl" works in tclsh or tclkit) and you need to set things up so "gcc" works. What I do is install the mingw system, and set up the PATH so "gcc" works from the command line. That's it. -jcw


Paolo Noli: A little question: How to call a tcl commands from inside a c funcion declared with the statement "ccode"? (I need this to implement a callback procedure.. but I think this can be an interesting tip for others people. :)


Instructions for installing critcl in an existing "traditional" (i.e. non-starkit) Tcl installation

  • Critcl is supplied as a Starkit; but perhaps you would like to use it with a traditional Tcl distribution, e.g to use your collection of extensions
  • these instructions are console commands for a Linux/Unix system. Please adapt for other platforms.
  • download the tclkit binary for your platform, and the starkits critcl.kit, and sdx.kit
  • follow the instructions for installing tclkit (you can remove it at the end if you wish)
  • check that tclkit and critcl.kit work correctly: run the command
  tclkit critcl.kit test-critcl.tcl
  • (where tclkit is in your command path and critcl.kit, test-critcl.tcl are in your current directory; the file test-critcl.tcl is listed below)
  • you should see the console output "three times 123 is 369"
  • now use sdx.kit to unpack critcl.kit: run the command
  tclkit sdx.kit critcl.kit
  • (where tclkit is in your command path and sdx.kit, critcl.kit are in your current directory)
  • a directory critcl.vfs will be created that holds the contents of critcl.kit: cd to this folder's lib subfolder
  cd critcl.vfs/lib
  • ensure that you are the root user and that the folders and their contents have appropriate ownership
  • copy the contents of this folder to the lib folder of your Tcl installation, and then cd there
  cp -a * /path/to/tcl/lib
  cd /path/to/tcl/lib
  • open the file app-critcl/critcl.tcl in a text editor and do the following...
  • ... in the first non-comment line, 'exec tclkit $0 ${1+"$@"}', replace 'tclkit' with 'tclsh'
  • ... find the line with 'Wikit::init' and comment it out (alternatively, install the files from the critcl.vfs/doc folder somewhere on your machine, and specify the path in the 'file join' statement)
  • make the file app-critcl/critcl.tcl executable and symlink it from a directory in your PATH, e.g.
  ln -s /path/to/tcl/lib/app-critcl/critcl.tcl /usr/local/bin/critcl
  • delete your Critcl cache directory ~/.critcl so the next command will test the correct functioning of the compiler
  • now test this installation of Critcl:
  tclsh test-critcl.tcl
  • as before, you should see the console output "three times 123 is 369"
  • once again delete your Critcl cache directory ~/.critcl, and now test the command-line critcl tool (which provides useful command-line options)
  critcl test-critcl.tcl
  • if this is successful, you can now use Critcl from your existing Tcl installation, and you no longer need the tclkit or starkit files to use Critcl

The file test-critcl.tcl:

  lappend auto_path .
  package require critcl

  critcl::cproc triple {int i} int {
     return i * 3;    /* this is C code */
  }
  puts "three times 123 is [triple 123]"

Category Critcl