Go to the first, previous, next, last section, table of contents.


Tcl/Tk notes

Versions

Where to get Tcl/Tk

The primary Tcl/Tk site is:

http://www.scriptics.com

Using extensions

With Tcl 7.5 and later, many extensions are modules which can be simply loaded by the load tcl-command.

To be able to use extensions which can not be loaded by the load command, the tcltk resource has to be relinked. Below is an example of using BLT-1.9 with Tcl/Tk v.7.4/4.0 and SICStus:

# File: `Makefile'
MAKE= make
MFLAGS=
CC= cc
CFLAGS= -O
INCR_CFLAGS= -DSPDLL
SHSFX= so
STSFX= s.o

SP_INC= /usr/local/include
SP_LIB= /usr/local/lib/sicstus
SP_SRC= /usr/local/src/sicstus3

TCLINC= -I/usr/local/include
TCLLIB= -L/usr/local/lib -lBLT -ltk4.0 -ltcl7.4 -lX11 -lsocket -lm

TCLTKOBJS= $(SP_SRC)/library/tcltk/tcl.o $(SP_SRC)/library/tcltk/tk.o \
        $(SP_SRC)/library/tcltk/util.o $(SP_SRC)/library/tcltk/tkterm.o \
        blttkapi.o

tcltk.$(SHSFX): tcltk.pl blttkapi.o
        (cd $(SP_SRC)/library/tcltk; \
                $(MAKE) $(MFLAGS) dyn MAKE=$(MAKE) MFLAGS='$(MFLAGS)' \
                        CC=$(CC) CFLAGS='-DSICSTUS $(CFLAGS)' \
                        SP_INC=$(SP_INC) TCLINC='$(TCLINC)' \
                        INCR_CFLAGS='$(INCR_CFLAGS)' )
        $(SP_LIB)/bin/splfr tcltk tcltk +o $(TCLTKOBJS) +l $(TCLLIB)

tcltk.$(STSFX): tcltk.pl blttkapi.o
        (cd $(SP_SRC)/library/tcltk; \
                $(MAKE) $(MFLAGS) stat MAKE=$(MAKE) MFLAGS='$(MFLAGS)' \
                        CC=$(CC) CFLAGS='-DSICSTUS $(CFLAGS)' \
                        SP_INC=$(SP_INC) TCLINC='$(TCLINC)' \
                        INCR_CFLAGS= )
        $(SP_LIB)/bin/splfr tcltk tcltk +static +o $(TCLTKOBJS) +l $(TCLLIB)

tcltk.pl:
        ln -s $(SP_SRC)/library/tcltk.pl

blttkapi.o:     blttkapi.c
        $(CC) -c $(CFLAGS) $(INCR_CFLAGS) $(TCLINC) blttkapi.c
/* File: `blttkapi.c' */
#include <tcl.h>

int Tcl_AppInit(interp)
     Tcl_Interp *interp;
{
  /*
   * Call the init procedures for included packages.  Each call should
   * look like this:
   *
   * if (Mod_Init(interp) == TCL_ERROR) {
   *     return TCL_ERROR;
   * }
   *
   * where "Mod" is the name of the module.
   */
        if (Blt_Init(interp) != TCL_OK) {
            return TCL_ERROR;
         }

  /*
   * Call Tcl_CreateCommand for application-specific commands, if
   * they weren't already created by the init procedures called above.
   */
  
  /*
   * Specify a user-specific startup file to invoke if the application
   * is run interactively.  Typically the startup file is "~/.apprc"
   * where "app" is the name of the application.  If this line is deleted
   * then no user-specific startup file will be run under any conditions.
   */

  /*
  tcl_RcFileName = "~/.wishrc";
  */
  return TCL_OK;
}
% File: `test.pl'
:- use_module(tcltk).

main :-
        tk_new([], I),
        % calendar from blt-1.9/demos
        tcl_eval(I, 'source calendar', _),
        tk_main_loop.

Typical make invocation:

% make tcltk.so \
        CC=gcc CFLAGS=-g \
        SP_INC=/src/sicstus/san/bin/sun4sol/include \
        SP_LIB=/src/sicstus/san/bin/sun4sol/bin \
        SP_SRC=/home/san/sicstus3 \
        TCLINC=-I/src/sicstus/san/TclTk/inc40 \
        TCLLIB='-L/src/sicstus/san/TclTk/blt-1.9/src -lBLT -L/usr/local/lib -ltk4.0 -ltcl7.4 -lX11 -lsocket -lm -L/usr/gnu/lib/gcc-lib/sparc-sun-solaris2.5/2.7.2.1 -lgcc'


Go to the first, previous, next, last section, table of contents.