1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
Tcl 8.1b1 for Windows
by Scott Stanton
Scriptics Corporation
scott.stanton@scriptics.com
RCS: @(#) $Id: README,v 1.1.2.4 1998/12/11 01:32:14 stanton Exp $
1. Introduction
---------------
This is the directory where you configure and compile the Windows
version of Tcl. This directory also contains source files for Tcl
that are specific to Microsoft Windows. The rest of this file
contains information specific to the Windows version of Tcl.
2. Distribution notes
---------------------
Tcl 8.1 for Windows is distributed in binary form in addition to the
common source release. The binary distribution is a self-extracting
archive with a built-in installation script.
Look for the binary release in the same location as the source release
(ftp.scriptics.com:/pub/tcl or any of the mirror sites). For most users,
the binary release will be much easier to install and use. You only
need the source release if you plan to modify the core of Tcl, or if
you need to compile with a different compiler. With the addition of
the dynamic loading interface, it is no longer necessary to have the
source distribution in order to build and use extensions.
3. Compiling Tcl
----------------
In order to compile Tcl for Windows, you need the following items:
Tcl 8.1 Source Distribution (plus any patches)
Borland C++ 4.52 (both 16-bit and 32-bit compilers)
or
Visual C++ 2.x/4.x/5.x
Visual C++ 1.5 (to build tcl1680.dll for Win32s support of exec)
In practice, the 8.1.a2 release is built with Visual C++ 5.0
In the "win" subdirectory of the source release, you will find two
files called "makefile.bc" and "makefile.vc". These are the makefiles
for the Borland and Visual C++ compilers respectively. You should
copy the appropriate one to "makefile" and update the paths at the
top of the file to reflect your system configuration. Now you can use
"make" (or "nmake" for VC++) to build the tcl libraries and the tclsh
executable.
In order to use the binaries generated by these makefiles, you will
need to place the Tcl script library files someplace where Tcl can
find them. Tcl looks in one of three places for the library files:
1) The path specified in the environment variable "TCL_LIBRARY".
2) In the lib\tcl8.1 directory under the installation directory
as specified in the registry:
For Windows NT & 95:
HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.1
For Win32s:
HKEY_CLASSES_ROOT\SOFTWARE\Scriptics\Tcl\8.1\
3) Relative to the directory containing the current .exe.
Tcl will look for a directory "..\lib\tcl8.1" relative to the
directory containing the currently running .exe.
Note that in order to run tclsh81.exe, you must ensure that tcl81.dll
and tclpip81.dll (plus tcl1681.dll under Win32s) are on your path, in
the system directory, or in the directory containing tclsh81.exe.
4. Building Extensions
----------------------
With the Windows compilers you have to worry about how you export symbols
from DLLs. tcl.h defines a few macros to help solve this problem:
EXTERN - all Tcl_ function prototypes use this macro, which implies
they are exported. You'll see this used in tcl.h and tk.h.
You should use this in your exported procedures.
However, this is not the whole story.
TCL_STORAGE_CLASS - this is really an import/export flag, depending on if you are
importing symbols from a DLL (i.e., a user of the DLL), or if
you are exporting symbols from the DLL (i.e., you are building it.)
The EXTERN macro includes TCL_STORAGE_CLASS.
TCL_STORAGE_CLASS is defined to be either DLLIMPORT or DLLEXPORT as
described below.
STATIC_BUILD - define this if you are *not* building a DLL
(e.g., a main program)
DLL_BUILD - define this if you *are* building a DLL
DLLIMPORT - If STATIC_BUILD is defined, this becomes nothing.
(On UNIX, DLLIMPORT is defined to be empty)
Otherwise, this this expands to __declspec(dllimport)
DLLEXPORT - If STATIC_BUILD is defined, this becomes nothing.
(On UNIX, DLLEXPORT is defined to be empty)
Otherwise, this this expands to __declspec(dllexport)
EXPORT(type, func)
For the Borland compiler, you need to export functions differently.
The DLLEXPORT macro is empty, and instead you need to use
EXPORT because they had a different order. Your declaration will
look like
EXTERN EXPORT(int, Foo_Init)(Tcl_Interp *interp);
We have not defined EXPORT anywhere. You can paste this into your C file:
#ifndef STATIC_BUILD
#if defined(_MSC_VER)
# define EXPORT(a,b) __declspec(dllexport) a b
# define DllEntryPoint DllMain
#else
# if defined(__BORLANDC__)
# define EXPORT(a,b) a _export b
# else
# define EXPORT(a,b) a b
# endif
#endif
#endif
How to use these:
Assume your extension is named Foo. In its Makefile, define
BUILD_Foo so that you know you are building Foo and not using it.
Then, in your main header file, foo.h, conditionally define
EXPORT to be either DLLIMPORT or DLLEXPORT based on the
presense of BUILD_Foo, like this:
#ifndef _FOO
#define _FOO
#include "tcl.h"
/* Additional includes go here */
/*
* if the BUILD_foo macro is defined, the assumption is that we are
* building the dynamic library.
*/
#ifdef BUILD_Foo
# undef TCL_STORAGE_CLASS
# define TCL_STORAGE_CLASS DLLEXPORT
#endif
/*
* Function prototypes for this module.
*/
EXTERN int Foo_Init _ANSI_ARGS_((Tcl_Interp *interp));
EXTERN int Foo_SafeInit _ANSI_ARGS_((Tcl_Interp *interp));
/* Additional prototypes go here */
/*
* end of foo.h
* reset TCL_STORAGE_CLASS to DLLIMPORT.
*/
# undef TCL_STORAGE_CLASS
# define TCL_STORAGE_CLASS DLLIMPORT
#endif /* _FOO */
In your C file, put EXTERN before then functions you need to export.
If you use Borland, you'll need to use the old EXPORT macro, too.
5. Test suite
-------------
This distribution contains an extensive test suite for Tcl. Some of
the tests are timing dependent and will fail from time to time. If a
test is failing consistently, please send us a bug report with as much
detail as you can manage.
In order to run the test suite, you build the "test" target using the
appropriate makefile for your compiler.
6. Known Bugs
-------------
Here is the current list of known bugs/missing features for the
Windows version of Tcl:
- Clock command fails to handle daylight savings time boundaries for
things like "last week".
- Background processes aren't properly detached on NT.
- File events only work on sockets and pipes.
- Files/console/serial ports don't support nonblocking I/O.
- Environment variables containing international characters aren't
imported correctly.
If you have comments or bug reports for the Windows version of Tcl,
please use the form at:
http://www.scriptics.com/support/bugForm.html
If you have comments or bug reports for the Windows version of Tk,
please direct them to the comp.lang.tcl newsgroup or the
wintcl@tclconsortium.org mailing list.
|