Updated 2008-06-18 12:41:58 by LV

Tcl was designed from the beginning to be easy for a C programmer to add new Tcl commands written in C, or, as you might regard it, accessing C functions from Tcl. Recipes for doing so appear in the books [ fill in the details ...] and magazine articles [fill in the details ...]. Online tutorials, including "SampleExtension" and "Hello World as a C extension", also are apt for beginners.

However, a number of schemes have come along that make life easier for someone that has a need to do this.

Probably the easiest way to call C from Tcl is via CriTcl. CriTcl allows you to embed C functions within a Tcl script, compiling and cached the results the first time they are invoked. From then on the compiled C code will be dynamically loaded. You can also use CritBind to pre-build libraries or executables.

See CriTcl builds C extensions on-the-fly for more information. stevel

What: SWIG
 Where: http://swig.sourceforge.net/
	ftp://swig.sourceforge.net/pub/swig/MacSWIG1.1p2.sea.hqx
	ftp://ftp.caos.kun.nl/pub/misc/jswig.tar.gz
	ftp://ftp.caos.kun.nl/pub/misc/jswig/jswig1.2a3.tar.gz
	ftp://ftp.caos.kun.nl/pub/misc/jswig/jswig.1.3a3.zip
	ftp://astro.phys.cmu.edu/pub/ptak/mac_swig_example/
	http://starship.skyport.net/crew/robind/python/
	http://www.neurop2.ruhr-uni-bochum.de/%7Ecozzi/swigeiffel/
	http://starship.skyport.net/crew/robind/python#swig
	http://superk.physics.sunysb.edu/%7Emcgrew/guile
	http://www.goto.info.waseda.ac.jp/%7Efukusima/ruby/swig-e.html
	http://sourceforge.net/patch/?func=detailpatch&patch_id=101430&group_id=1645
	http://www.geocities.com/digitalshmoo/dev/swig/
 Description: Tool designed to make it easier to integrate functions
	written in C/C++ with Tcl 7 and 8/Tk, Perl 4 and 5, Python and Guile.
	SWIG is a compiler that takes ANSI C/C++ declarations and builds a
	scripting language interface for a number of different languages.
	Works for Unix and Win32.
	The SWIG documentation and a tutorial are available on SourceForge.
	Jswig is an extension by Harco de Hilster which generates
	 Java native code classes from the SWIG templates.
	 Should be extracted into SWIG1.1/Examples/java/.
	Example of getting SWIG working with Macintosh, by Andy Ptak,
	 at CMU.  There are also SWIG/python patches available by
	 Robin Dunn.  SWIG interface for Eiffel has been made available
	 by Alex Cozzi, who provides a version for SWIG 1.1p5 as well as one
	 for SWIG 1.2a1.
	The waseda site has a SWIG module for Ruby.
	The sourceforge patch reference provides Guile 1.3.4 support.
	The digitalsmoo site contains a sample of using SWIG to create
	 shadow objects for C++ classes wrapped by perl.
	Currently version 1.3.9 is available.
 Updated: 07/2001
 Contact: mailto:beazley@cs.uchicago.edu (David Beazley)
	mailto:harcoh@caos.kun.nl (Harco de Hilster)
	mailto:ptak@astro.phys.cmu.edu (Andy Ptak)

In a Windows environment, alternatives include ffidl, tcom, and optcl.

Also note RS's clever article "Extending Tcl in C from Tcl".

Still more links are available at [1].

A complementary subject is "How to embed Tcl in C applications".

We need to give guidance to the online Tcl and Tk Tutorials and books [2] that relate to this subject. Among the latter, the books by John Ousterhout and Brent Welch (and co-writers) are probably the ones most frequently recommended for explaining extension-writing.

[Talk about IPC, extension theory, ...]

escargo - Dead link as of 28 Apr 2005. (all links still dead 2 Dec 2007) Not much found by Google of Phillippe or (Philippe) Le Foll since 2000.

LV you should be able to find version 1.30 of jWrap at the procplace URL. Is there anything at archive.com?
 What: jWrap
 Where: http://www.fridu.com/Html/jWrap.html
	http://perso.wanadoo.fr/philippe.lefoll/Html/jWrap-linux-009.tgz
	http://perso.wanadoo.fr/philippe.lefoll/Html/jWrap-win32-009.zip
	ftp://ftp.procplace.com/pub/tcl/sorted/packages-8.0/devel/jWrap-1.30-linux86.tgz
 Description: jWrap parses C/C++ headers or source in order to
	automatically produce a C/C++ glue stub that can be
	linked with your component library to produce a loadable Tcl
	extension.  It uses Tcl 8 object representation very heavily.
	The author claims that the resulting code is faster than similar
	mechanisms such as SWIG or cTest.  jWrap allows jTcl to overload
	C++ methods or a C++ program to call jTcl methods with no
	modification to the C++ code.  Binary versions for Linux, Win32
	and Solaris are available.
 Updated: 04/1999
 Contact: mailto:phillf@fridu.com (Phillippe Le Foll >

Another tool for wrapping C headers into C stubs callable from Tcl is called SWIG.