1mNAME0m
       load - Load machine code and initialize new commands.

1mSYNOPSIS0m
       1mload 4m22mfileName0m
       1mload 4m22mfileName24m 4mpackageName0m
       1mload 4m22mfileName24m 4mpackageName24m 4minterp0m


1mDESCRIPTION0m
       This  command  loads  binary  code  from  a file into the application's
       address space and calls an initialization procedure in the  package  to
       incorporate  it  into an interpreter.  4mfileName24m is the name of the file
       containing the code;  its exact form varies from system to  system  but
       on  most  systems  it  is  a  shared  library, such as a 1m.so 22mfile under
       Solaris or a DLL under Windows.  4mpackageName24m is the name of  the  pack-
       age,  and  is  used to compute the name of an initialization procedure.
       4minterp24m is the path name of the interpreter into which to load the pack-
       age (see the 1minterp 22mmanual entry for details); if 4minterp24m is omitted, it
       defaults to the interpreter in which the 1mload 22mcommand was invoked.

       Once the file has been loaded into the application's address space, one
       of two initialization procedures will be invoked in the new code.  Typ-
       ically the initialization procedure will add  new  commands  to  a  Tcl
       interpreter.  The name of the initialization procedure is determined by
       4mpackageName24m and whether or not the target interpreter is  a  safe  one.
       For  normal  interpreters the name of the initialization procedure will
       have the form 4mpkg24m1m_Init22m, where 4mpkg24m is the  same  as  4mpackageName24m  except
       that  the first letter is converted to upper case and all other letters
       are converted to lower case.  For example, if  4mpackageName24m  is  1mfoo  22mor
       1mFOo22m, the initialization procedure's name will be 1mFoo_Init22m.

       If  the  target interpreter is a safe interpreter, then the name of the
       initialization procedure will be 4mpkg24m1m_SafeInit 22minstead of 4mpkg24m1m_Init22m.  The
       4mpkg24m1m_SafeInit  22mfunction should be written carefully, so that it initial-
       izes the safe interpreter only with partial functionality  provided  by
       the  package  that is safe for use by untrusted code. For more informa-
       tion on Safe-Tcl, see the 1msafe 22mmanual entry.

       The initialization procedure must match the following prototype:
              typedef int Tcl_PackageInitProc(Tcl_Interp *4minterp24m);
       The 4minterp24m argument identifies the interpreter in which the package  is
       to  be  loaded.   The  initialization  procedure  must return 1mTCL_OK 22mor
       1mTCL_ERROR 22mto indicate whether or not it completed successfully;  in the
       event of an error it should set the interpreter's result to point to an
       error message.  The result of the  1mload  22mcommand  will  be  the  result
       returned by the initialization procedure.

       The  actual  loading of a file will only be done once for each 4mfileName0m
       in an application.  If a given 4mfileName24m is loaded into multiple  inter-
       preters,  then  the first 1mload 22mwill load the code and call the initial-
       ization procedure;  subsequent 1mload22ms will call the initialization  pro-
       cedure without loading the code again.  It is not possible to unload or
       reload a package.

       The 1mload 22mcommand also supports packages that are statically linked with
       the  application, if those packages have been registered by calling the
       1mTcl_StaticPackage 22mprocedure.  If 4mfileName24m  is  an  empty  string,  then
       4mpackageName24m must be specified.

       If 4mpackageName24m is omitted or specified as an empty string, Tcl tries to
       guess the name of  the  package.   This  may  be  done  differently  on
       different  platforms.   The  default  guess, which is used on most UNIX
       platforms, is to take the last element of 4mfileName24m, strip off the first
       three  characters if they are 1mlib22m, and use any following alphabetic and
       underline characters as the module name.  For example, the command 1mload0m
       1mlibxyz4.2.so  22muses the module name 1mxyz 22mand the command 1mload bin/last.so0m
       1m{} 22muses the module name 1mlast22m.

       If 4mfileName24m is an empty string, then  4mpackageName24m  must  be  specified.
       The  1mload  22mcommand  first searches for a statically loaded package (one
       that has been registered by calling the 1mTcl_StaticPackage 22mprocedure) by
       that  name;  if  one is found, it is used.  Otherwise, the 1mload 22mcommand
       searches for a dynamically loaded package by that name, and uses it  if
       it  is found.  If several different files have been 1mload22med with differ-
       ent versions of the package, Tcl picks the file that was loaded  first.


1mPORTABILITY ISSUES0m
       1mWindows0m
              When  a  load  fails  with "library not found" error, it is also
              possible that a dependent library was not  found.   To  see  the
              dependent  libraries,  type  ``dumpbin -imports <dllname>'' in a
              DOS console to see what the library must import.  When loading a
              DLL  in  the  current directory, Windows will ignore ``./'' as a
              path specifier and use  a  search  heuristic  to  find  the  DLL
              instead.  To avoid this, load the DLL with
                  load [file join [pwd] mylib.DLL]


1mBUGS0m
       If  the  same  file is 1mload22med by different 4mfileName24ms, it will be loaded
       into the process's address space multiple times.  The behavior of  this
       varies  from  system  to  system (some systems may detect the redundant
       loads, others may not).


1mSEE ALSO0m
       1minfo sharedlibextension22m, Tcl_StaticPackage(3), safe(n)


1mKEYWORDS0m
