Tcl_Init

See Building a custom tclsh for a usage example. Tcl_init is documented on the library man page, where it says:

To access the procedures in the Tcl library, an application should source the file init.tcl in the library, for example with the Tcl command

source [file join [info library] init.tcl]

If the library procedure Tcl_Init is invoked from an application's Tcl_AppInit procedure, this happens automatically. The code in init.tcl will define the unknown procedure and arrange for the other procedures to be loaded on-demand using the auto-load mechanism defined below.


Donald Porter wrote in comp.lang.tcl:

  Bob Techentin  <[email protected]> wrote:

  > Correct me if I'm wrong, Jeff, but you still need to have a Tcl script
  > library for your application to function.  You may not need a Tcl
  > installation on systems which will run this program with an embedded
  > interpreter, but you must have TCL_LIBRARY pointing to a directory
  > with at least init.tcl.

  It really depends on what the application is expecting from its
  embedded Tcl library.

  Tcl_CreateInterp() creates a fully functional Tcl interpreter.
  All that Tcl_Init() adds (by finding and evaluating the installed
  init.tcl file) is the definition of additional commands in the
  interpreter.  See the latest interp(n) documentation released in
  Tcl 8.4a3 for a complete list of these commands.  A nearly complete
  list is in the library(n) man page.

  https://www.tcl-lang.org/man/tcl/TclCmd/library.htm

  If you just need an internal command interpreter without all the
  additional comands provided by Tcl_Init(), Tcl can provide
  that without needing Tcl's script library on the system.  Just
  be sure your application that embeds Tcl doesn't call Tcl_Init() !

  > Are there additional standard Tcl script library components that are
  > required?  I might venture the guess that you would _need_ auto.tcl,
  > init.tcl, package.tcl, and the encoding directory.  You may really
  > want safe.tcl.  Are there others that are required?

  Note that the commands added by Tcl_Init() form the fundamental
  basis for both Tcl's autoloading and package loading facilities.
  So, if your purpose in embedding Tcl is to gain access to Tcl's
  rich universe of useful packages (including Tk!), then yes, you
  must have a working Tcl_Init(), meaning you must have some means
  of accessing (or replacing) init.tcl and the other files in the
  Tcl script library.

  Solving this problem is a major part of the various techniques
  used to create "single file" Tcl applications [1].  Let me know
  if you need pointers to the lists of those.  They get posted
  here about weekly.

1: See deployment

In Another c.l.t discussion from 2001 , more is revealed.