Building Tcl extensions

Purpose: Discuss what it takes for a software author to create a Tcl extension that can be used by others.

[Too bad wiki doesn't really support an outline mode of text input...]


  • See the Tcl Core Team team's example extension ftp://www.tcl.tk/pub/tcl/examples/tea/
  • Read the TEA Tcl Extension Architecture document [1 ]
  • Users of MacOS, Windows, and probably other non-Unix platforms have serious problems with TEA, due to its heavy reliance on Unix like utilities. To date, no alternative has been implemented that provides ease of use, reusability, cross platform support, etc. Lots of bugs and problems have been reported - no solutions have arisen. Note that some extensions [someone fill in examples here please] have been written which use TEA to build on Windows and Unix; I don't know whether any also build on some kind of pseudo-unix MacOS package or not.
  • Determine whether the extension can and will be cross platform
  • Is this relevant to your extension?
  • Are you interested in supporting cross platform?
  • What needs to be done?
  • Decide whether you want a script library extension versus compiled (or mixed) library extension.
  • If script only, what are the core issues to consider?
  • Portable code - see the Tcl Developer's Xchange [2 ] style guide
  • What installation aids do you provide? Options include:
  • Nothing - let the user figure it out
  • Text describing what to do
  • Tcl script to assist in configuration / installation
  • configure / makefile to assist in configuration
  • What documentation do you supply? Options include:
  • None - let the users read the source *
  • Plain text - everyone has an editor these days
  • HTML - everyone has a browser these days
  • *roff man pages - it's what everyone considers
  • XML - it's the coming thing
  • Other formats (TeX, texinfo, PostScript, PDF, WinHelp, etc.)
  • What format is used for MacOS?
  • What additional issues can be considered?
  • If compiled language only, what are the core issues to consider?
  • Which compiler?
  • ANSI C only?
  • Portable C?
  • ANSI C++ ?
  • Portable C++ ?
  • Other (FORTRAN, Ada, ...)?
  • Be certain to use Tcl functions when available, to gain as much cross platform help as possible
  • Be certain to use Tcl's compat library when your platform(s) functions are broken
  • Provide your own compat library functions when you need to replace the functions on a particular plaforms
  • Propose new Tcl cross platform library functions when you need something that isn't already in Tcl. See TIP for this process.
  • Tools for writing extensions: SWIG, mktclapp [3 ], critcl
  • the so-called RTFS system

LV: What is RTFS?

MS: RTF source, I guess.

LV: Appears to be some sort of DOS compatibility file system. - RS: no, it's the ultimate documentation system - "read the f* source"...


LV See also Solutions for Extension Building, "Hello World as a C extension", ...


Building Tcl DLL's for Windows