1 |
578 |
markom |
-------------------
|
2 |
|
|
Dynamic Loading Tix
|
3 |
|
|
-------------------
|
4 |
|
|
|
5 |
|
|
In this text, the phrase "a version of Tcl" stands for a version of
|
6 |
|
|
Tcl from the standard Sun distribution or the ITcl distribution.
|
7 |
|
|
|
8 |
|
|
BINARY VERSION
|
9 |
|
|
==============
|
10 |
|
|
|
11 |
|
|
Tix can be built to work with different versions of Tcl. A Tix
|
12 |
|
|
dynamic library built for a particular version of Tcl works only
|
13 |
|
|
with that version. To make it possible to install Tix binaries
|
14 |
|
|
that support multiple versions of Tcl, and prevent the loading of
|
15 |
|
|
Tix binaries into incompatible versions of Tcl, Tix uses a special
|
16 |
|
|
"binary versioning" system:
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
BINARY VERSION FOR STANDARD TCL DISTRIBUTION
|
20 |
|
|
|
21 |
|
|
If you use Tix version a.b and build a Tix binary file for Tcl
|
22 |
|
|
version x.y, the "binary version" of this Tix binary file will
|
23 |
|
|
be a.b.x.y. For example, if you build the Tix 4.1 shared
|
24 |
|
|
library for Tcl 7.6, the binary version is 4.1.7.6.
|
25 |
|
|
|
26 |
|
|
BINARY VERSION FOR ITCL DISTRIBUTION
|
27 |
|
|
|
28 |
|
|
If you use Tix version a.b and build a Tix binary file for an
|
29 |
|
|
ITcl distribution which contains Tcl version x.y., the "binary
|
30 |
|
|
version" of this Tix binary file will be a.b.x.y.1. For
|
31 |
|
|
example, if you build the Tix 4.1 shared library for Itcl 2.2
|
32 |
|
|
(which contains Tcl 7.6), the binary version is 4.1.7.6.1.
|
33 |
|
|
|
34 |
|
|
In short, the extra ".1" version number indicates whether a Tix
|
35 |
|
|
binary is compile for standard Tcl or Itcl.
|
36 |
|
|
|
37 |
|
|
Naming of shared libraries
|
38 |
|
|
==========================
|
39 |
|
|
|
40 |
|
|
A Tix shared library compiled for a standard Tcl distribution
|
41 |
|
|
is named libtix${BIN_VERSION}${SHLIB_SUFFIX}. For example,
|
42 |
|
|
with Tix version 4.1 and Tcl version 7.6:
|
43 |
|
|
|
44 |
|
|
libtix4.1.7.6.so
|
45 |
|
|
|
46 |
|
|
With Tix version 4.1 and ITcl version 2.1 (which includes Tcl
|
47 |
|
|
version 7.5):
|
48 |
|
|
|
49 |
|
|
libtix4.1.7.5.1.so
|
50 |
|
|
|
51 |
|
|
Naming of executable files
|
52 |
|
|
==========================
|
53 |
|
|
|
54 |
|
|
The Tix executable (which contains Tcl, Tk and Tix) is called
|
55 |
|
|
"tixwish${BIN_VERSION}". For example, the executables for the shared
|
56 |
|
|
libraries mentioned above are
|
57 |
|
|
|
58 |
|
|
tixwish4.1.7.6
|
59 |
|
|
tixwish4.1.7.5.1
|
60 |
|
|
|
61 |
|
|
GENERATING A TIX BINARY VERSION
|
62 |
|
|
===============================
|
63 |
|
|
|
64 |
|
|
The following Tcl procedure can be used to generate a Tix binary
|
65 |
|
|
version for a particular version combination of Tix and Tcl:
|
66 |
|
|
|
67 |
|
|
proc tixBinVer {tixVer} {
|
68 |
|
|
global tcl_version
|
69 |
|
|
|
70 |
|
|
if {[string compare [info command @scope] ""]} {
|
71 |
|
|
# We are running inside Itcl
|
72 |
|
|
return $tixVer.$tcl_version.1
|
73 |
|
|
} else {
|
74 |
|
|
return $tixVer.$tcl_version
|
75 |
|
|
}
|
76 |
|
|
}
|
77 |
|
|
|
78 |
|
|
LOADING TIX WITH THE "load" COMMAND
|
79 |
|
|
===================================
|
80 |
|
|
|
81 |
|
|
To dynamic load Tix with the "load" command, you can use the
|
82 |
|
|
tixBinVer procedure to generate a Tix binary version number. If
|
83 |
|
|
the Tix 4.1 shared library is located in the directory $dir, it
|
84 |
|
|
can be loaded by
|
85 |
|
|
|
86 |
|
|
load [file join $dir libtix[tixBinVer 4.1][info sharedlibextension]] Tix
|
87 |
|
|
|
88 |
|
|
The above command may not work on platforms that do not support
|
89 |
|
|
the "." character inside shared library names. For example, on
|
90 |
|
|
SunOS, the command must be modified as:
|
91 |
|
|
|
92 |
|
|
set ver [tixBinVer 4.1]
|
93 |
|
|
regsub -all {[.]} $ver "" ver
|
94 |
|
|
load [file join $dir libtix$ver[info sharedlibextension].1] Tix
|
95 |
|
|
|
96 |
|
|
To avoid the need of platform specific code and having to hard
|
97 |
|
|
code the location of the shared into your scripts, it's
|
98 |
|
|
recommended you use instead the "package require" command to load
|
99 |
|
|
a Tix dynamic library, as outlined below.
|
100 |
|
|
|
101 |
|
|
LOADING TIX WITH THE "package require" COMMAND
|
102 |
|
|
==============================================
|
103 |
|
|
|
104 |
|
|
If you have properly installed Tix in your system, you can
|
105 |
|
|
dynamically load Tix with the following command:
|
106 |
|
|
|
107 |
|
|
package require -exact Tix [tixBinVer 4.1]
|
108 |
|
|
|
109 |
|
|
Note that the "-exact" switch must be used so that only a
|
110 |
|
|
Tix shared library compatible with the given version of Tcl is
|
111 |
|
|
loaded. (If you omit the -exact switch, "package require" may load
|
112 |
|
|
in Tix 4.1.7.6 even the correct version should be 4.1.7.5.1.)
|
113 |
|
|
|
114 |
|
|
LOADING TIX SAM WITH THE "package require" COMMAND
|
115 |
|
|
==================================================
|
116 |
|
|
|
117 |
|
|
The Tix StandAlone Module (SAM), when properly installed, can also
|
118 |
|
|
be loaded using the "package require" command:
|
119 |
|
|
|
120 |
|
|
package require -exact Tixsam [tixBinVer 4.1]
|
121 |
|
|
|
122 |
|
|
Note: when you load it the "Tixsam" package, the Tix package will
|
123 |
|
|
be loaded automatically. You need not, and must not, "package
|
124 |
|
|
require" the Tix package at the same time.
|
125 |
|
|
|
126 |
|
|
Read the file docs/SAModules.txt for more details on StandAlone
|
127 |
|
|
Modules.
|