version 2, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
PERLWIN32 |
|
|
2 |
!!!PERLWIN32 |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
BUGS AND CAVEATS |
|
|
7 |
AUTHORS |
|
|
8 |
SEE ALSO |
|
|
9 |
HISTORY |
|
|
10 |
---- |
|
|
11 |
!!NAME |
|
|
12 |
|
|
|
13 |
|
|
|
14 |
perlwin32 - Perl under Win32 |
|
|
15 |
!!SYNOPSIS |
|
|
16 |
|
|
|
17 |
|
|
|
18 |
These are instructions for building Perl under Windows (9x, |
|
|
19 |
NT and 2000). |
|
|
20 |
!!DESCRIPTION |
|
|
21 |
|
|
|
22 |
|
|
|
23 |
Before you start, you should glance through the |
|
|
24 |
README file found in the top-level directory |
|
|
25 |
to which the Perl distribution was extracted. Make sure you |
|
|
26 |
read and understand the terms under which this software is |
|
|
27 |
being distributed. |
|
|
28 |
|
|
|
29 |
|
|
|
30 |
Also make sure you read `` BUGS AND CAVEATS |
|
|
31 |
'' below for the known limitations of this |
|
|
32 |
port. |
|
|
33 |
|
|
|
34 |
|
|
|
35 |
The INSTALL file in the perl top-level has |
|
|
36 |
much information that is only relevant to people building |
|
|
37 |
Perl on Unix-like systems. In particular, you can safely |
|
|
38 |
ignore any information that talks about |
|
|
39 |
``Configure''. |
|
|
40 |
|
|
|
41 |
|
|
|
42 |
You may also want to look at two other options for building |
|
|
43 |
a perl that will work on Windows NT: the |
|
|
44 |
README .cygwin and README .os2 |
|
|
45 |
files, each of which give a different set of rules to build |
|
|
46 |
a Perl that will work on Win32 platforms. Those two methods |
|
|
47 |
will probably enable you to build a more Unix-compatible |
|
|
48 |
perl, but you will also need to download and use various |
|
|
49 |
other build-time and run-time support software described in |
|
|
50 |
those files. |
|
|
51 |
|
|
|
52 |
|
|
|
53 |
This set of instructions is meant to describe a so-called |
|
|
54 |
``native'' port of Perl to Win32 platforms. The resulting |
|
|
55 |
Perl requires no additional software to run (other than what |
|
|
56 |
came with your operating system). Currently, this port is |
|
|
57 |
capable of using one of the following |
|
|
58 |
compilers: |
|
|
59 |
|
|
|
60 |
|
|
|
61 |
Borland C++ version 5.02 or later |
|
|
62 |
Microsoft Visual C++ version 4.2 or later |
|
|
63 |
Mingw32 with GCC version 2.95.2 or better |
|
|
64 |
The last of these is a high quality freeware compiler. Support for it is still experimental. (Older versions of GCC are known not to work.) |
|
|
65 |
|
|
|
66 |
|
2 |
perry |
67 |
This port currently supports !MakeMaker (the set of modules |
1 |
perry |
68 |
that is used to build extensions to perl). Therefore, you |
|
|
69 |
should be able to build and install most extensions found in |
|
|
70 |
the CPAN sites. See ``Usage Hints'' below for |
|
|
71 |
general hints about this. |
|
|
72 |
|
|
|
73 |
|
|
|
74 |
__Setting Up__ |
|
|
75 |
|
|
|
76 |
|
|
|
77 |
Make |
|
|
78 |
|
|
|
79 |
|
|
|
80 |
You need a ``make'' program to build the sources. If you are |
|
|
81 |
using Visual C ++ under Windows |
|
|
82 |
NT or 2000, nmake will work. All other builds |
|
|
83 |
need dmake. |
|
|
84 |
|
|
|
85 |
|
|
|
86 |
dmake is a freely available make that has very nice macro |
|
|
87 |
features and parallelability. |
|
|
88 |
|
|
|
89 |
|
|
|
90 |
A port of dmake for Windows is available from: |
|
|
91 |
|
|
|
92 |
|
|
|
93 |
http://www.cpan.org/authors/id/GSAR/dmake-4.1pl1-win32.zip |
|
|
94 |
(This is a fixed version of the original dmake sources obtained from http://www.wticorp.com/dmake/. As of version 4.1PL1, the original sources did not build as shipped and had various other problems. A patch is included in the above fixed version.) |
|
|
95 |
|
|
|
96 |
|
|
|
97 |
Fetch and install dmake somewhere on your path (follow the |
|
|
98 |
instructions in the README .NOW |
|
|
99 |
file). |
|
|
100 |
|
|
|
101 |
|
|
|
102 |
There exists a minor coexistence problem with dmake and |
|
|
103 |
Borland C ++ compilers. Namely, if a |
|
|
104 |
distribution has C files named with mixed case letters, they |
|
|
105 |
will be compiled into appropriate .obj-files named with all |
|
|
106 |
lowercase letters, and every time dmake is invoked to bring |
|
|
107 |
files up to date, it will try to recompile such files again. |
|
|
108 |
For example, Tk distribution has a lot of such files, |
|
|
109 |
resulting in needless recompiles everytime dmake is invoked. |
|
|
110 |
To avoid this, you may use the script ``sncfnmcs.pl'' after |
|
|
111 |
a successful build. It is available in the win32 |
|
|
112 |
subdirectory of the Perl source distribution. |
|
|
113 |
|
|
|
114 |
|
|
|
115 |
Command Shell |
|
|
116 |
|
|
|
117 |
|
|
|
118 |
Use the default ``cmd'' shell that comes with |
|
|
119 |
NT . Some versions of the popular 4DOS/NT |
|
|
120 |
shell have incompatibilities that may cause you trouble. If |
|
|
121 |
the build fails under that shell, try building again with |
|
|
122 |
the cmd shell. |
|
|
123 |
|
|
|
124 |
|
|
|
125 |
The nmake Makefile also has known incompatibilities with the |
|
|
126 |
``command.com'' shell that comes with Windows 9x. You will |
|
|
127 |
need to use dmake and makefile.mk to build under Windows |
|
|
128 |
9x. |
|
|
129 |
|
|
|
130 |
|
|
|
131 |
The surest way to build it is on Windows NT , |
|
|
132 |
using the cmd shell. |
|
|
133 |
|
|
|
134 |
|
|
|
135 |
Make sure the path to the build directory does not contain |
|
|
136 |
spaces. The build usually works in this circumstance, but |
|
|
137 |
some tests will fail. |
|
|
138 |
|
|
|
139 |
|
|
|
140 |
Borland C ++ |
|
|
141 |
|
|
|
142 |
|
|
|
143 |
If you are using the Borland compiler, you will need dmake. |
|
|
144 |
(The make that Borland supplies is seriously crippled and |
2 |
perry |
145 |
will not work for !MakeMaker builds.) |
1 |
perry |
146 |
|
|
|
147 |
|
|
|
148 |
See ``Make'' above. |
|
|
149 |
|
|
|
150 |
|
|
|
151 |
Microsoft Visual C ++ |
|
|
152 |
|
|
|
153 |
|
|
|
154 |
The nmake that comes with Visual C ++ will |
|
|
155 |
suffice for building. You will need to run the |
|
|
156 |
VCVARS32 .BAT file, usually found somewhere |
|
|
157 |
like C:MSDEV4.2BIN. This will set your build |
|
|
158 |
environment. |
|
|
159 |
|
|
|
160 |
|
|
|
161 |
You can also use dmake to build using Visual C |
|
|
162 |
++ ; provided, however, you set |
|
|
163 |
OSRELEASE to ``microsft'' (or whatever the |
|
|
164 |
directory name under which the Visual C dmake configuration |
|
|
165 |
lives) in your environment and edit win32/config.vc to |
|
|
166 |
change ``make=nmake'' into ``make=dmake''. The latter step |
|
|
167 |
is only essential if you want to use dmake as your default |
2 |
perry |
168 |
make for building extensions using !MakeMaker. |
1 |
perry |
169 |
|
|
|
170 |
|
|
|
171 |
Mingw32 with GCC |
|
|
172 |
|
|
|
173 |
|
|
|
174 |
GCC-2 .95.2 binaries can be downloaded |
|
|
175 |
from: |
|
|
176 |
|
|
|
177 |
|
|
|
178 |
ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/ |
|
|
179 |
You also need dmake. See ``Make'' above on how to get it. |
|
|
180 |
|
|
|
181 |
|
|
|
182 |
The GCC-2 .95.2 bundle comes with Mingw32 |
|
|
183 |
libraries and headers. |
|
|
184 |
|
|
|
185 |
|
|
|
186 |
Make sure you install the binaries that work with |
|
|
187 |
MSVCRT .DLL as indicated in the |
|
|
188 |
README for the GCC bundle. You |
|
|
189 |
may need to set up a few environment variables (usually ran |
|
|
190 |
from a batch file). |
|
|
191 |
|
|
|
192 |
|
|
|
193 |
There are a couple of problems with the version of |
|
|
194 |
gcc-2.95.2-msvcrt.exe released 7 November 1999: |
|
|
195 |
|
|
|
196 |
|
|
|
197 |
It left out a fix for certain command line quotes. To fix |
|
|
198 |
this, be sure to download and install the file |
|
|
199 |
fixes/quote-fix-msvcrt.exe from the above ftp |
|
|
200 |
location. |
|
|
201 |
|
|
|
202 |
|
|
|
203 |
The definition of the fpos_t type in stdio.h may be wrong. |
|
|
204 |
If your stdio.h has this problem, you will see an exception |
|
|
205 |
when running the test t/lib/io_xs.t. To fix this, change the |
|
|
206 |
typedef for fpos_t from ``long'' to ``long long'' in the |
|
|
207 |
file i386-mingw32msvc/include/stdio.h, and |
|
|
208 |
rebuild. |
|
|
209 |
|
|
|
210 |
|
|
|
211 |
A potentially simpler to install (but probably |
|
|
212 |
soon-to-be-outdated) bundle of the above package with the |
|
|
213 |
mentioned fixes already applied is available |
|
|
214 |
here: |
|
|
215 |
|
|
|
216 |
|
2 |
perry |
217 |
http://downloads.!ActiveState.com/pub/staff/gsar/gcc-2.95.2-msvcrt.zip |
|
|
218 |
ftp://ftp.!ActiveState.com/pub/staff/gsar/gcc-2.95.2-msvcrt.zip |
1 |
perry |
219 |
|
|
|
220 |
|
|
|
221 |
__Building__ |
|
|
222 |
|
|
|
223 |
|
|
|
224 |
Make sure you are in the ``win32'' subdirectory under the |
|
|
225 |
perl toplevel. This directory contains a ``Makefile'' that |
|
|
226 |
will work with versions of nmake that come with Visual C |
|
|
227 |
++ , and a dmake ``makefile.mk'' that will |
|
|
228 |
work for all supported compilers. The defaults in the dmake |
|
|
229 |
makefile are setup to build using the GCC |
|
|
230 |
compiler. |
|
|
231 |
|
|
|
232 |
|
|
|
233 |
Edit the makefile.mk (or Makefile, if you're using nmake) |
|
|
234 |
and change the values of INST_DRV and |
|
|
235 |
INST_TOP . You can also enable various build |
|
|
236 |
flags. These are explained in the makefiles. |
|
|
237 |
|
|
|
238 |
|
|
|
239 |
You will have to make sure that CCTYPE is set |
|
|
240 |
correctly and that CCHOME points to wherever |
|
|
241 |
you installed your compiler. |
|
|
242 |
|
|
|
243 |
|
|
|
244 |
The default value for CCHOME in the makefiles |
|
|
245 |
for Visual C ++ may not be correct for some |
|
|
246 |
versions. Make sure the default exists and is |
|
|
247 |
valid. |
|
|
248 |
|
|
|
249 |
|
|
|
250 |
If you have either the source or a library that contains |
|
|
251 |
''des_fcrypt()'', enable the appropriate option in the |
|
|
252 |
makefile. ''des_fcrypt()'' is not bundled with the |
|
|
253 |
distribution due to US Government |
|
|
254 |
restrictions on the export of cryptographic software. |
|
|
255 |
Nevertheless, this routine is part of the ``libdes'' library |
|
|
256 |
(written by Eric Young) which is widely available worldwide, |
|
|
257 |
usually along with SSLeay (for example, |
|
|
258 |
``ftp://fractal.mta.ca/pub/crypto/SSLeay/DES/''). Set |
|
|
259 |
CRYPT_SRC to the name of the file that |
|
|
260 |
implements ''des_fcrypt()''. Alternatively, if you have |
|
|
261 |
built a library that contains ''des_fcrypt()'', you can |
|
|
262 |
set CRYPT_LIB to point to the library name. |
|
|
263 |
The location above contains many versions of the ``libdes'' |
|
|
264 |
library, all with slightly different implementations of |
|
|
265 |
''des_fcrypt()''. Older versions have a single, |
|
|
266 |
self-contained file (fcrypt.c) that implements |
|
|
267 |
''crypt()'', so they may be easier to use. A patch |
|
|
268 |
against the fcrypt.c found in libdes-3.06 is in |
|
|
269 |
des_fcrypt.patch. |
|
|
270 |
|
|
|
271 |
|
|
|
272 |
Perl will also build without ''des_fcrypt()'', but the |
|
|
273 |
''crypt()'' builtin will fail at run time. |
|
|
274 |
|
|
|
275 |
|
|
|
276 |
Be sure to read the instructions near the top of the |
|
|
277 |
makefiles carefully. |
|
|
278 |
|
|
|
279 |
|
|
|
280 |
Type ``dmake'' (or ``nmake'' if you are using that |
|
|
281 |
make). |
|
|
282 |
|
|
|
283 |
|
|
|
284 |
This should build everything. Specifically, it will create |
|
|
285 |
perl.exe, perl56.dll at the perl toplevel, and various other |
|
|
286 |
extension dll's under the libauto directory. If the build |
|
|
287 |
fails for any reason, make sure you have done the previous |
|
|
288 |
steps correctly. |
|
|
289 |
|
|
|
290 |
|
|
|
291 |
__Testing__ |
|
|
292 |
|
|
|
293 |
|
|
|
294 |
Type ``dmake test'' (or ``nmake test''). This will run most |
|
|
295 |
of the tests from the testsuite (many tests will be |
|
|
296 |
skipped). |
|
|
297 |
|
|
|
298 |
|
|
|
299 |
There should be no test failures when running under Windows |
|
|
300 |
NT 4.0 or Windows 2000. Many tests |
|
|
301 |
''will'' fail under Windows 9x due to the inferior |
|
|
302 |
command shell. |
|
|
303 |
|
|
|
304 |
|
|
|
305 |
Some test failures may occur if you use a command shell |
|
|
306 |
other than the native ``cmd.exe'', or if you are building |
|
|
307 |
from a path that contains spaces. So don't do |
|
|
308 |
that. |
|
|
309 |
|
|
|
310 |
|
|
|
311 |
If you are running the tests from a emacs shell window, you |
|
|
312 |
may see failures in op/stat.t. Run ``dmake test-notty'' in |
|
|
313 |
that case. |
|
|
314 |
|
|
|
315 |
|
|
|
316 |
If you're using the Borland compiler, you may see a failure |
|
|
317 |
in op/taint.t arising from the inability to find the Borland |
|
|
318 |
Runtime DLLs on the system default path. You will need to |
|
|
319 |
copy the DLLs reported by the messages from where Borland |
|
|
320 |
chose to install it, into the Windows system directory |
|
|
321 |
(usually somewhere like C:WINNTSYSTEM32) and rerun the |
|
|
322 |
test. |
|
|
323 |
|
|
|
324 |
|
|
|
325 |
If you're using Borland compiler versions 5.2 and below, you |
|
|
326 |
may run into problems finding the correct header files when |
|
|
327 |
building extensions. For example, building the ``Tk'' |
|
|
328 |
extension may fail because both perl and Tk contain a header |
|
|
329 |
file called ``patchlevel.h''. The latest Borland compiler |
|
|
330 |
(v5.5) is free of this misbehaviour, and it even supports an |
|
|
331 |
option -VI- for backward (bugward) compatibility for using |
|
|
332 |
the old Borland search algorithm to locate header |
|
|
333 |
files. |
|
|
334 |
|
|
|
335 |
|
|
|
336 |
Please report any other failures as described under `` |
|
|
337 |
BUGS AND CAVEATS ''. |
|
|
338 |
|
|
|
339 |
|
|
|
340 |
__Installation__ |
|
|
341 |
|
|
|
342 |
|
|
|
343 |
Type ``dmake install'' (or ``nmake install''). This will put |
|
|
344 |
the newly built perl and the libraries under whatever |
|
|
345 |
INST_TOP points to in the Makefile. It will also |
|
|
346 |
install the pod documentation under |
|
|
347 |
$INST_TOP$VERSIONlibpod and HTML |
|
|
348 |
versions of the same under |
|
|
349 |
$INST_TOP$VERSIONlibpodhtml. To use the Perl you |
|
|
350 |
just installed, you will need to add two components to your |
|
|
351 |
PATH environment variable, |
|
|
352 |
$INST_TOP$VERSIONbin and |
|
|
353 |
$INST_TOP$VERSIONbin$ARCHNAME. For |
|
|
354 |
example: |
|
|
355 |
|
|
|
356 |
|
|
|
357 |
set PATH c:perl5.6.0bin;c:perl5.6.0binMSWin32-x86;%PATH% |
|
|
358 |
If you opt to comment out INST_VER and INST_ARCH in the makefiles, the installation structure is much simpler. In that case, it will be sufficient to add a single entry to the path, for instance: |
|
|
359 |
|
|
|
360 |
|
|
|
361 |
set PATH c:perlbin;%PATH% |
|
|
362 |
|
|
|
363 |
|
|
|
364 |
__Usage Hints__ |
|
|
365 |
|
|
|
366 |
|
|
|
367 |
Environment Variables |
|
|
368 |
|
|
|
369 |
|
|
|
370 |
The installation paths that you set during the build get |
|
|
371 |
compiled into perl, so you don't have to do anything |
|
|
372 |
additional to start using that perl (except add its location |
|
|
373 |
to your PATH variable). |
|
|
374 |
|
|
|
375 |
|
|
|
376 |
If you put extensions in unusual places, you can set |
|
|
377 |
PERL5LIB to a list of paths separated by |
|
|
378 |
semicolons where you want perl to look for libraries. Look |
|
|
379 |
for descriptions of other environment variables you can set |
|
|
380 |
in perlrun. |
|
|
381 |
|
|
|
382 |
|
|
|
383 |
You can also control the shell that perl uses to run |
|
|
384 |
''system()'' and backtick commands via |
|
|
385 |
PERL5SHELL . See perlrun. |
|
|
386 |
|
|
|
387 |
|
|
|
388 |
Perl does not depend on the registry, but it can look up |
|
|
389 |
certain default values if you choose to put them there. Perl |
|
|
390 |
attempts to read entries from |
|
|
391 |
HKEY_CURRENT_USERSoftwarePerl and |
|
|
392 |
HKEY_LOCAL_MACHINESoftwarePerl. Entries in the |
|
|
393 |
former override entries in the latter. One or more of the |
|
|
394 |
following entries (of type REG_SZ or |
|
|
395 |
REG_EXPAND_SZ ) may be set: |
|
|
396 |
|
|
|
397 |
|
|
|
398 |
lib-$] version-specific standard library path to add to @INC |
|
|
399 |
lib standard library path to add to @INC |
|
|
400 |
sitelib-$] version-specific site library path to add to @INC |
|
|
401 |
sitelib site library path to add to @INC |
|
|
402 |
vendorlib-$] version-specific vendor library path to add to @INC |
|
|
403 |
vendorlib vendor library path to add to @INC |
|
|
404 |
PERL* fallback for all %ENV lookups that begin with |
|
|
405 |
Note the $] in the above is not literal. Substitute whatever version of perl you want to honor that entry, e.g. 5.6.0. Paths must be separated with semicolons, as usual on win32. |
|
|
406 |
|
|
|
407 |
|
|
|
408 |
File Globbing |
|
|
409 |
|
|
|
410 |
|
|
|
411 |
By default, perl handles file globbing using the File::Glob |
|
|
412 |
extension, which provides portable globbing. |
|
|
413 |
|
|
|
414 |
|
|
|
415 |
If you want perl to use globbing that emulates the quirks of |
|
|
416 |
DOS filename conventions, you might want to |
2 |
perry |
417 |
consider using File::!DosGlob to override the internal |
|
|
418 |
''glob()'' implementation. See File::!DosGlob for |
1 |
perry |
419 |
details. |
|
|
420 |
|
|
|
421 |
|
|
|
422 |
Using perl from the command line |
|
|
423 |
|
|
|
424 |
|
|
|
425 |
If you are accustomed to using perl from various |
|
|
426 |
command-line shells found in UNIX |
|
|
427 |
environments, you will be less than pleased with what |
|
|
428 |
Windows offers by way of a command shell. |
|
|
429 |
|
|
|
430 |
|
|
|
431 |
The crucial thing to understand about the Windows |
|
|
432 |
environment is that the command line you type in is |
|
|
433 |
processed twice before Perl sees it. First, your command |
|
|
434 |
shell (usually CMD .EXE on Windows |
|
|
435 |
NT , and COMMAND .COM on |
|
|
436 |
Windows 9x) preprocesses the command line, to handle |
|
|
437 |
redirection, environment variable expansion, and location of |
|
|
438 |
the executable to run. Then, the perl executable splits the |
|
|
439 |
remaining command line into individual arguments, using the |
|
|
440 |
C runtime library upon which Perl was built. |
|
|
441 |
|
|
|
442 |
|
|
|
443 |
It is particularly important to note that neither the shell |
|
|
444 |
nor the C runtime do any wildcard expansions of command-line |
|
|
445 |
arguments (so wildcards need not be quoted). Also, the |
|
|
446 |
quoting behaviours of the shell and the C runtime are |
|
|
447 |
rudimentary at best (and may, if you are using a |
|
|
448 |
non-standard shell, be inconsistent). The only (useful) |
|
|
449 |
quote character is the double quote ( |
|
|
450 |
|
|
|
451 |
|
|
|
452 |
The Windows NT documentation has almost no |
|
|
453 |
description of how the quoting rules are implemented, but |
|
|
454 |
here are some general observations based on experiments: The |
|
|
455 |
C runtime breaks arguments at spaces and passes them to |
|
|
456 |
programs in argc/argv. Double quotes can be used to prevent |
|
|
457 |
arguments with spaces in them from being split up. You can |
|
|
458 |
put a double quote in an argument by escaping it with a |
|
|
459 |
backslash and enclosing the whole argument within double |
|
|
460 |
quotes. The backslash and the pair of double quotes |
|
|
461 |
surrounding the argument will be stripped by the C |
|
|
462 |
runtime. |
|
|
463 |
|
|
|
464 |
|
|
|
465 |
The file redirection characters `` |
|
|
466 |
|
|
|
467 |
|
|
|
468 |
Here are some examples of usage of the ``cmd'' |
|
|
469 |
shell: |
|
|
470 |
|
|
|
471 |
|
|
|
472 |
This prints two doublequotes: |
|
|
473 |
|
|
|
474 |
|
|
|
475 |
perl -e |
|
|
476 |
This does the same: |
|
|
477 |
|
|
|
478 |
|
|
|
479 |
perl -e |
|
|
480 |
This prints ``bar'' and writes ``foo'' to the file ``blurch'': |
|
|
481 |
|
|
|
482 |
|
|
|
483 |
perl -e |
|
|
484 |
This prints ``foo'' (``bar'' disappears into nowhereland): |
|
|
485 |
|
|
|
486 |
|
|
|
487 |
perl -e |
|
|
488 |
This prints ``bar'' and writes ``foo'' into the file ``blurch'': |
|
|
489 |
|
|
|
490 |
|
|
|
491 |
perl -e |
|
|
492 |
This pipes ``foo'' to the ``less'' pager and prints ``bar'' on the console: |
|
|
493 |
|
|
|
494 |
|
|
|
495 |
perl -e |
|
|
496 |
This pipes ``foonbarn'' to the less pager: |
|
|
497 |
|
|
|
498 |
|
|
|
499 |
perl -le |
|
|
500 |
This pipes ``foo'' to the pager and writes ``bar'' in the file ``blurch'': |
|
|
501 |
|
|
|
502 |
|
|
|
503 |
perl -e |
|
|
504 |
Discovering the usefulness of the ``command.com'' shell on Windows 9x is left as an exercise to the reader :) |
|
|
505 |
|
|
|
506 |
|
|
|
507 |
One particularly pernicious problem with the 4NT command |
|
|
508 |
shell for Windows NT is that it (nearly) |
|
|
509 |
always treats a % character as indicating that environment |
|
|
510 |
variable expansion is needed. Under this shell, it is |
|
|
511 |
therefore important to always double any % characters which |
|
|
512 |
you want Perl to see (for example, for hash variables), even |
|
|
513 |
when they are quoted. |
|
|
514 |
|
|
|
515 |
|
|
|
516 |
Building Extensions |
|
|
517 |
|
|
|
518 |
|
|
|
519 |
The Comprehensive Perl Archive Network ( CPAN |
|
|
520 |
) offers a wealth of extensions, some of which require a C |
|
|
521 |
compiler to build. Look in http://www.cpan.org/ for more |
|
|
522 |
information on CPAN . |
|
|
523 |
|
|
|
524 |
|
|
|
525 |
Note that not all of the extensions available from |
|
|
526 |
CPAN may work in the Win32 environment; you |
|
|
527 |
should check the information at http://testers.cpan.org/ |
|
|
528 |
before investing too much effort into porting modules that |
|
|
529 |
don't readily build. |
|
|
530 |
|
|
|
531 |
|
|
|
532 |
Most extensions (whether they require a C compiler or not) |
|
|
533 |
can be built, tested and installed with the standard |
|
|
534 |
mantra: |
|
|
535 |
|
|
|
536 |
|
|
|
537 |
perl Makefile.PL |
|
|
538 |
$MAKE |
|
|
539 |
$MAKE test |
|
|
540 |
$MAKE install |
|
|
541 |
where $MAKE is whatever 'make' program you have configured perl to use. Use ``perl -V:make'' to find out what this is. Some extensions may not provide a testsuite (so ``$MAKE test'' may not do anything or fail), but most serious ones do. |
|
|
542 |
|
|
|
543 |
|
|
|
544 |
It is important that you use a supported 'make' program, and |
|
|
545 |
ensure Config.pm knows about it. If you don't have nmake, |
|
|
546 |
you can either get dmake from the location mentioned earlier |
|
|
547 |
or get an old version of nmake reportedly available |
|
|
548 |
from: |
|
|
549 |
|
|
|
550 |
|
|
|
551 |
ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe |
|
|
552 |
Another option is to use the make written in Perl, available from CPAN: |
|
|
553 |
|
|
|
554 |
|
|
|
555 |
http://www.cpan.org/authors/id/NI-S/Make-0.03.tar.gz |
|
|
556 |
You may also use dmake. See ``Make'' above on how to get it. |
|
|
557 |
|
|
|
558 |
|
2 |
perry |
559 |
Note that !MakeMaker actually emits makefiles with different |
1 |
perry |
560 |
syntax depending on what 'make' it thinks you are using. |
|
|
561 |
Therefore, it is important that one of the following values |
|
|
562 |
appears in Config.pm: |
|
|
563 |
|
|
|
564 |
|
2 |
perry |
565 |
make='nmake' # !MakeMaker emits nmake syntax |
|
|
566 |
make='dmake' # !MakeMaker emits dmake syntax |
|
|
567 |
any other value # !MakeMaker emits generic make syntax |
1 |
perry |
568 |
(e.g GNU make, or Perl make) |
|
|
569 |
If the value doesn't match the 'make' program you want to use, edit Config.pm to fix it. |
|
|
570 |
|
|
|
571 |
|
|
|
572 |
If a module implements XSUBs, you will need one of the |
|
|
573 |
supported C compilers. You must make sure you have set up |
|
|
574 |
the environment for the compiler for command-line |
|
|
575 |
compilation. |
|
|
576 |
|
|
|
577 |
|
|
|
578 |
If a module does not build for some reason, look carefully |
|
|
579 |
for why it failed, and report problems to the module author. |
|
|
580 |
If it looks like the extension building support is at fault, |
|
|
581 |
report that with full details of how the build failed using |
|
|
582 |
the perlbug utility. |
|
|
583 |
|
|
|
584 |
|
|
|
585 |
Command-line Wildcard Expansion |
|
|
586 |
|
|
|
587 |
|
|
|
588 |
The default command shells on DOS descendant |
|
|
589 |
operating systems (such as they are) usually do not expand |
|
|
590 |
wildcard arguments supplied to programs. They consider it |
|
|
591 |
the application's job to handle that. This is commonly |
|
|
592 |
achieved by linking the application (in our case, perl) with |
|
|
593 |
startup code that the C runtime libraries usually provide. |
|
|
594 |
However, doing that results in incompatible perl versions |
|
|
595 |
(since the behavior of the argv expansion code differs |
|
|
596 |
depending on the compiler, and it is even buggy on some |
|
|
597 |
compilers). Besides, it may be a source of frustration if |
|
|
598 |
you use such a perl binary with an alternate shell that |
|
|
599 |
*does* expand wildcards. |
|
|
600 |
|
|
|
601 |
|
|
|
602 |
Instead, the following solution works rather well. The nice |
|
|
603 |
things about it are 1) you can start using it right away; 2) |
|
|
604 |
it is more powerful, because it will do the right thing with |
|
|
605 |
a pattern like */*/*.c; 3) you can decide whether you |
|
|
606 |
do/don't want to use it; and 4) you can extend the method to |
|
|
607 |
add any customizations (or even entirely different kinds of |
|
|
608 |
wildcard expansion). |
|
|
609 |
|
|
|
610 |
|
|
|
611 |
C: |
|
|
612 |
Note there are two distinct steps there: 1) You'll have to create Wild.pm and put it in your perl lib directory. 2) You'll need to set the PERL5OPT environment variable. If you want argv expansion to be the default, just set PERL5OPT in your default startup environment. |
|
|
613 |
|
|
|
614 |
|
|
|
615 |
If you are using the Visual C compiler, you can get the C |
|
|
616 |
runtime's command line wildcard expansion built into perl |
|
|
617 |
binary. The resulting binary will always expand unquoted |
|
|
618 |
command lines, which may not be what you want if you use a |
|
|
619 |
shell that does that for you. The expansion done is also |
|
|
620 |
somewhat less powerful than the approach suggested |
|
|
621 |
above. |
|
|
622 |
|
|
|
623 |
|
|
|
624 |
Win32 Specific Extensions |
|
|
625 |
|
|
|
626 |
|
|
|
627 |
A number of extensions specific to the Win32 platform are |
|
|
628 |
available from CPAN . You may find that many |
|
|
629 |
of these extensions are meant to be used under the |
|
|
630 |
Activeware port of Perl, which used to be the only native |
|
|
631 |
port for the Win32 platform. Since the Activeware port does |
|
|
632 |
not have adequate support for Perl's extension building |
|
|
633 |
tools, these extensions typically do not support those tools |
|
|
634 |
either and, therefore, cannot be built using the generic |
|
|
635 |
steps shown in the previous section. |
|
|
636 |
|
|
|
637 |
|
|
|
638 |
To ensure smooth transitioning of existing code that uses |
2 |
perry |
639 |
the !ActiveState port, there is a bundle of Win32 extensions |
|
|
640 |
that contains all of the !ActiveState extensions and most |
1 |
perry |
641 |
other Win32 extensions from CPAN in source |
2 |
perry |
642 |
form, along with many added bugfixes, and with !MakeMaker |
1 |
perry |
643 |
support. This bundle is available at: |
|
|
644 |
|
|
|
645 |
|
|
|
646 |
http://www.cpan.org/authors/id/GSAR/libwin32-0.151.zip |
|
|
647 |
See the README in that distribution for building and installation instructions. Look for later versions that may be available at the same location. |
|
|
648 |
|
|
|
649 |
|
|
|
650 |
Running Perl Scripts |
|
|
651 |
|
|
|
652 |
|
|
|
653 |
Perl scripts on UNIX use the ``#!'' (a.k.a |
|
|
654 |
``shebang'') line to indicate to the OS that |
|
|
655 |
it should execute the file using perl. Win32 has no |
|
|
656 |
comparable means to indicate arbitrary files are |
|
|
657 |
executables. |
|
|
658 |
|
|
|
659 |
|
|
|
660 |
Instead, all available methods to execute plain text files |
|
|
661 |
on Win32 rely on the file ``extension''. There are three |
|
|
662 |
methods to use this to execute perl scripts: |
|
|
663 |
|
|
|
664 |
|
|
|
665 |
1 |
|
|
666 |
|
|
|
667 |
|
|
|
668 |
There is a facility called ``file extension associations'' |
|
|
669 |
that will work in Windows NT 4.0. This can be |
|
|
670 |
manipulated via the two commands ``assoc'' and ``ftype'' |
|
|
671 |
that come standard with Windows NT 4.0. Type |
|
|
672 |
``ftype /?'' for a complete example of how to set this up |
|
|
673 |
for perl scripts (Say what? You thought Windows |
|
|
674 |
NT wasn't perl-ready? :). |
|
|
675 |
|
|
|
676 |
|
|
|
677 |
2 |
|
|
678 |
|
|
|
679 |
|
|
|
680 |
Since file associations don't work everywhere, and there are |
|
|
681 |
reportedly bugs with file associations where it does work, |
|
|
682 |
the old method of wrapping the perl script to make it look |
|
|
683 |
like a regular batch file to the OS , may be |
|
|
684 |
used. The install process makes available the ``pl2bat.bat'' |
|
|
685 |
script which can be used to wrap perl scripts into batch |
|
|
686 |
files. For example: |
|
|
687 |
|
|
|
688 |
|
|
|
689 |
pl2bat foo.pl |
|
|
690 |
will create the file `` FOO .BAT''. Note ``pl2bat'' strips any .pl suffix and adds a .bat suffix to the generated file. |
|
|
691 |
|
|
|
692 |
|
|
|
693 |
If you use the 4DOS/NT or similar command shell, note that |
|
|
694 |
``pl2bat'' uses the ``%*'' variable in the generated batch |
|
|
695 |
file to refer to all the command line arguments, so you may |
|
|
696 |
need to make sure that construct works in batch files. As of |
2 |
perry |
697 |
this writing, 4DOS/NT users will need a ``!ParameterChar = |
1 |
perry |
698 |
*'' statement in their 4NT.INI file or will need to execute |
|
|
699 |
``setdos /p*'' in the 4DOS/NT startup file to enable this to |
|
|
700 |
work. |
|
|
701 |
|
|
|
702 |
|
|
|
703 |
3 |
|
|
704 |
|
|
|
705 |
|
|
|
706 |
Using ``pl2bat'' has a few problems: the file name gets |
|
|
707 |
changed, so scripts that rely on $0 to find what |
|
|
708 |
they must do may not run properly; running ``pl2bat'' |
|
|
709 |
replicates the contents of the original script, and so this |
|
|
710 |
process can be maintenance intensive if the originals get |
|
|
711 |
updated often. A different approach that avoids both |
|
|
712 |
problems is possible. |
|
|
713 |
|
|
|
714 |
|
|
|
715 |
A script called ``runperl.bat'' is available that can be |
|
|
716 |
copied to any filename (along with the .bat suffix). For |
|
|
717 |
example, if you call it ``foo.bat'', it will run the file |
|
|
718 |
``foo'' when it is executed. Since you can run batch files |
|
|
719 |
on Win32 platforms simply by typing the name (without the |
|
|
720 |
extension), this effectively runs the file ``foo'', when you |
|
|
721 |
type either ``foo'' or ``foo.bat''. With this method, |
|
|
722 |
``foo.bat'' can even be in a different location than the |
|
|
723 |
file ``foo'', as long as ``foo'' is available somewhere on |
|
|
724 |
the PATH . If your scripts are on a |
|
|
725 |
filesystem that allows symbolic links, you can even avoid |
|
|
726 |
copying ``runperl.bat''. |
|
|
727 |
|
|
|
728 |
|
|
|
729 |
Here's a diversion: copy ``runperl.bat'' to ``runperl'', and |
|
|
730 |
type ``runperl''. Explain the observed behavior, or lack |
|
|
731 |
thereof. :) Hint: .gnidnats llits er'uoy fi ,``lrepnur'' |
|
|
732 |
eteled :tniH |
|
|
733 |
|
|
|
734 |
|
|
|
735 |
Miscellaneous Things |
|
|
736 |
|
|
|
737 |
|
|
|
738 |
A full set of HTML documentation is |
|
|
739 |
installed, so you should be able to use it if you have a web |
|
|
740 |
browser installed on your system. |
|
|
741 |
|
|
|
742 |
|
|
|
743 |
perldoc is also a useful tool for browsing |
|
|
744 |
information contained in the documentation, especially in |
|
|
745 |
conjunction with a pager like less (recent versions |
|
|
746 |
of which have Win32 support). You may have to set the |
|
|
747 |
PAGER environment variable to use a specific |
|
|
748 |
pager. ``perldoc -f foo'' will print information about the |
|
|
749 |
perl operator ``foo''. |
|
|
750 |
|
|
|
751 |
|
|
|
752 |
If you find bugs in perl, you can run perlbug to |
|
|
753 |
create a bug report (you may have to send it manually if |
|
|
754 |
perlbug cannot find a mailer on your |
|
|
755 |
system). |
|
|
756 |
!!BUGS AND CAVEATS |
|
|
757 |
|
|
|
758 |
|
|
|
759 |
Some of the built-in functions do not act exactly as |
|
|
760 |
documented in perlfunc, and a few are not implemented at |
|
|
761 |
all. To avoid surprises, particularly if you have had prior |
|
|
762 |
exposure to Perl in other operating environments or if you |
|
|
763 |
intend to write code that will be portable to other |
|
|
764 |
environments. See perlport for a reasonably definitive list |
|
|
765 |
of these differences. |
|
|
766 |
|
|
|
767 |
|
|
|
768 |
Not all extensions available from CPAN may |
|
|
769 |
build or work properly in the Win32 environment. See |
|
|
770 |
``Building Extensions''. |
|
|
771 |
|
|
|
772 |
|
|
|
773 |
Most socket() related calls are supported, but they |
|
|
774 |
may not behave as on Unix platforms. See perlport for the |
|
|
775 |
full list. |
|
|
776 |
|
|
|
777 |
|
|
|
778 |
Signal handling may not behave as on Unix platforms (where |
|
|
779 |
it doesn't exactly ``behave'', either :). For instance, |
|
|
780 |
calling die() or exit() from signal |
|
|
781 |
handlers will cause an exception, since most implementations |
|
|
782 |
of signal() on Win32 are severely crippled. Thus, |
|
|
783 |
signals may work only for simple things like setting a flag |
|
|
784 |
variable in the handler. Using signals under this port |
|
|
785 |
should currently be considered unsupported. |
|
|
786 |
|
|
|
787 |
|
|
|
788 |
Please send detailed descriptions of any problems and |
|
|
789 |
solutions that you may find to |
|
|
790 |
perlbug@perl.com'' |
|
|
791 |
''perl -V. |
|
|
792 |
!!AUTHORS |
|
|
793 |
|
|
|
794 |
|
|
|
795 |
Gary Ng |
|
|
796 |
|
|
|
797 |
|
|
|
798 |
Gurusamy Sarathy |
|
|
799 |
|
|
|
800 |
|
|
|
801 |
Nick Ing-Simmons |
|
|
802 |
|
|
|
803 |
|
|
|
804 |
This document is maintained by Gurusamy |
|
|
805 |
Sarathy. |
|
|
806 |
!!SEE ALSO |
|
|
807 |
|
|
|
808 |
|
|
|
809 |
perl |
|
|
810 |
!!HISTORY |
|
|
811 |
|
|
|
812 |
|
|
|
813 |
This port was originally contributed by Gary Ng around |
|
|
814 |
5.003_24, and borrowed from the Hip Communications port that |
|
|
815 |
was available at the time. Various people have made numerous |
|
|
816 |
and sundry hacks since then. |
|
|
817 |
|
|
|
818 |
|
|
|
819 |
Borland support was added in 5.004_01 (Gurusamy |
|
|
820 |
Sarathy). |
|
|
821 |
|
|
|
822 |
|
|
|
823 |
GCC/mingw32 support was added in 5.005 (Nick |
|
|
824 |
Ing-Simmons). |
|
|
825 |
|
|
|
826 |
|
|
|
827 |
Support for PERL_OBJECT was added in 5.005 |
2 |
perry |
828 |
(!ActiveState Tool Corp). |
1 |
perry |
829 |
|
|
|
830 |
|
|
|
831 |
Support for ''fork()'' emulation was added in 5.6 |
2 |
perry |
832 |
(!ActiveState Tool Corp). |
1 |
perry |
833 |
|
|
|
834 |
|
|
|
835 |
Win9x support was added in 5.6 (Benjamin |
|
|
836 |
Stuhl). |
|
|
837 |
|
|
|
838 |
|
|
|
839 |
Last updated: 1 April 2001 |
|
|
840 |
---- |