[win32] Various win32 fixes
[p5sagit/p5-mst-13.2.git] / README.win32
1 If you read this file _as_is_, just ignore the funny characters you
2 see. It is written in the POD format (see pod/perlpod.pod) which is
3 specially designed to be readable as is.
4
5 =head1 NAME
6
7 perlwin32 - Perl under Win32
8
9 =head1 SYNOPSIS
10
11 These are instructions for building Perl under Windows NT (versions
12 3.51 or 4.0), using Visual C++ (versions 2.0 through 5.0) or Borland
13 C++ (version 5.02 or later).  Currently, this port is reported to build
14 under Windows95 using the 4DOS shell--the default shell that infests
15 Windows95 will not work (see below).  Note this caveat is only about
16 B<building> perl.  Once built, you should be able to B<use> it on
17 either Win32 platform (modulo the problems arising from the inferior
18 command shell).
19
20 =head1 DESCRIPTION
21
22 Before you start, you should glance through the README file
23 found in the top-level directory where the Perl distribution
24 was extracted.  Make sure you read and understand the terms under
25 which this software is being distributed.
26
27 Also make sure you read L<BUGS AND CAVEATS> below for the
28 known limitations of this port.
29
30 The INSTALL file in the perl top-level has much information that is
31 only relevant to people building Perl on Unix-like systems.  In
32 particular, you can safely ignore any information that talks about
33 "Configure".
34
35 You may also want to look at two other options for building
36 a perl that will work on Windows NT:  the README.cygwin32 and
37 README.os2 files, which each give a different set of rules to build
38 a Perl that will work on Win32 platforms.  Those two methods will
39 probably enable you to build a more Unix-compatible perl, but you
40 will also need to download and use various other build-time and
41 run-time support software described in those files.
42
43 This set of instructions is meant to describe a so-called "native"
44 port of Perl to Win32 platforms.  The resulting Perl requires no
45 additional software to run (other than what came with your operating
46 system).  Currently, this port is capable of using either the
47 Microsoft Visual C++ compiler, or the Borland C++ compiler.  The
48 ultimate goal is to support the other major compilers that can
49 generally be used to build Win32 applications.
50
51 This port currently supports MakeMaker (the set of modules that
52 is used to build extensions to perl).  Therefore, you should be
53 able to build and install most extensions found in the CPAN sites.
54 See L<Usage Hints> below for general hints about this.
55
56 =head2 Setting Up
57
58 =over 4
59
60 =item Command Shell
61
62 Use the default "cmd" shell that comes with NT.  Some versions of the
63 popular 4DOS/NT shell have incompatibilities that may cause you trouble.
64 If the build fails under that shell, try building again with the cmd
65 shell.  The Makefile also has known incompatibilites with the "command.com"
66 shell that comes with Windows95, so building under Windows95 should
67 be considered "unsupported".  However, there have been reports of successful
68 build attempts using 4DOS/NT version 3.00 under Windows95, using dmake, but
69 your mileage may vary.
70
71 The surest way to build it is on WindowsNT, using the cmd shell.
72
73 =item Borland C++
74
75 If you are using the Borland compiler, you will need dmake, a freely
76 available make that has very nice macro features and parallelability.
77 (The make that Borland supplies is seriously crippled, and will not
78 work for MakeMaker builds.)
79
80 A port of dmake for win32 platforms is available from:
81
82     http://www-personal.umich.edu/~gsar/dmake-4.1-win32.zip
83
84 Fetch and install dmake somewhere on your path (follow the instructions
85 in the README.NOW file).
86
87 =item Microsoft Visual C++
88
89 The NMAKE that comes with Visual C++ will suffice for building.
90 If you did not choose to always initialize the Visual C++ compilation
91 environment variables when you installed Visual C++ on your system, you
92 will need to run the VCVARS32.BAT file usually found somewhere like
93 C:\MSDEV4.2\BIN.  This will set your build environment.
94
95 You can also use dmake to build using Visual C++, provided:
96 you set OSRELEASE to "microsft" (or whatever the directory name
97 under which the Visual C dmake configuration lives) in your environment,
98 and edit win32/config.vc to change "make=nmake" into "make=dmake".  The
99 latter step is only essential if you want to use dmake as your default
100 make for building extensions using MakeMaker.
101
102 =item Permissions
103
104 Depending on how you extracted the distribution, you have to make sure
105 some of the files are writable by you.  The easiest way to make sure of
106 this is to execute:
107
108         attrib -R *.* /S
109
110 from the perl toplevel directory.  You don't I<have> to do this if you
111 used the right tools to extract the files in the standard distribution,
112 but it doesn't hurt to do so.
113
114 =back
115
116 =head2 Building
117
118 =over 4
119
120 =item *
121
122 Make sure you are in the "win32" subdirectory under the perl toplevel.
123 This directory contains a "Makefile" that will work with
124 versions of NMAKE that come with Visual C++ ver. 2.0 and above, and
125 a dmake "makefile.mk" that will work for both Borland and Visual C++
126 builds.  The defaults in the dmake makefile are setup to build using the
127 Borland compiler.
128
129 =item *
130
131 Edit the Makefile (or makefile.mk, if using dmake) and change the values
132 of INST_DRV and INST_TOP.  If you are using Visual C++ ver. 2.0, uncomment
133 the line that sets "CCTYPE=MSVC20".  You can also enable various build
134 flags.
135
136 If you have either the source or a library that contains des_fcrypt(),
137 enable the appropriate option in the makefile.  des_fcrypt() is not
138 bundled with the distribution due to US Government restrictions
139 on the export of cryptographic software.  Nevertheless, this routine
140 is part of the "libdes" library (written by Ed Young) which is widely
141 available worldwide, usually along with SSLeay (for example:
142 "ftp://fractal.mta.ca/pub/crypto/SSLeay/DES/").  Set CRYPT_SRC to the
143 name of the file that implements des_fcrypt().  Alternatively, if
144 you have built a library that contains des_fcrypt(), you can set
145 CRYPT_LIB to point to the library name.
146
147 Perl will also build without des_fcrypt(), but the crypt() builtin will
148 fail at run time.
149
150 You will also have to make sure CCHOME points to wherever you installed
151 your compiler.
152
153 =item *
154
155 Type "nmake" (or "dmake" if you are using that make).
156
157 This should build everything.  Specifically, it will create perl.exe,
158 perl.dll, and perlglob.exe at the perl toplevel, and various other
159 extension dll's under the lib\auto directory.  If the build fails for
160 any reason, make sure you have done the previous steps correctly.
161
162 The build process may produce "harmless" compiler warnings (more or
163 less copiously, depending on how picky your compiler gets).  The
164 maintainers are aware of these warnings, thankyouverymuch. :)
165
166 When building using Visual C++, a perl95.exe will also get built.  This
167 executable is only needed on Windows95, and should be used instead of
168 perl.exe, and then only if you want sockets to work properly on Windows95.
169 This is necessitated by a bug in the Microsoft C Runtime that cannot be
170 worked around in the "normal" perl.exe.  perl95.exe gets built with its
171 own private copy of the C Runtime that is not accessible to extensions
172 (which see the DLL version of the CRT).  Be aware, therefore, that this
173 perl95.exe will have esoteric problems with extensions like perl/Tk that
174 themselves use the C Runtime heavily, or want to free() pointers
175 malloc()-ed by perl.
176
177 You can avoid the perl95.exe problems completely if you use Borland
178 C++ for building perl (perl95.exe is not needed and will not be built
179 in that case).
180
181 =back
182
183 =head2 Testing
184
185 Type "nmake test" (or "dmake test").  This will run most of the tests from
186 the testsuite (many tests will be skipped, and but no test should fail).
187
188 If some tests do fail, it may be because you are using a different command
189 shell than the native "cmd.exe".
190
191 If you used the Borland compiler, you may see a failure in op/taint.t
192 arising from the inability to find the Borland Runtime DLLs on the system
193 default path.  You will need to copy the DLLs reported by the messages
194 from where Borland chose to install it, into the Windows system directory
195 (usually somewhere like C:\WINNT\SYSTEM32), and rerun the test.
196
197 Please report any other failures as described under L<BUGS AND CAVEATS>.
198
199 =head2 Installation
200
201 Type "nmake install" (or "dmake install").  This will put the newly
202 built perl and the libraries under whatever C<INST_TOP> points to in the
203 Makefile.  It will also install the pod documentation under
204 C<$INST_TOP\lib\pod> and HTML versions of the same under
205 C<$INST_TOP\lib\pod\html>.  To use the Perl you just installed,
206 set your PATH environment variable to C<$INST_TOP\bin>.
207
208 =head2 Usage Hints
209
210 =over 4
211
212 =item Environment Variables
213
214 The installation paths that you set during the build get compiled
215 into perl, so you don't have to do anything additional to start
216 using that perl (except add its location to your PATH variable).
217
218 If you put extensions in unusual places, you can set PERL5LIB
219 to a list of paths separated by semicolons where you want perl
220 to look for libraries.  Look for descriptions of other environment
221 variables you can set in L<perlrun>.
222
223 You can also control the shell that perl uses to run system() and
224 backtick commands via PERL5SHELL.  See L<perlrun>.
225
226 Sometime in the future, some of the configuration information
227 for perl will be moved into the Windows registry.
228
229 =item File Globbing
230
231 By default, perl spawns an external program to do file globbing.
232 The install process installs both a perlglob.exe and a perlglob.bat
233 that perl can use for this purpose.  Note that with the default
234 installation, perlglob.exe will be found by the system before
235 perlglob.bat.
236
237 perlglob.exe relies on the argv expansion done by the C Runtime of
238 the particular compiler you used, and therefore behaves very
239 differently depending on the Runtime used to build it.  To preserve
240 compatiblity, perlglob.bat (a perl script/module that can be
241 used portably) is installed.  Besides being portable, perlglob.bat
242 also offers enhanced globbing functionality.
243
244 If you want perl to use perlglob.bat instead of perlglob.exe, just
245 delete perlglob.exe from the install location (or move it somewhere
246 perl cannot find).  Using File::DosGlob.pm (which is the same
247 as perlglob.bat) to override the internal CORE::glob() works about 10
248 times faster than spawing perlglob.exe, and you should take this
249 approach when writing new modules.  See File::DosGlob for details.
250
251 =item Using perl from the command line
252
253 If you are accustomed to using perl from various command-line
254 shells found in UNIX environments, you will be less than pleased
255 with what Windows NT offers by way of a command shell.
256
257 The crucial thing to understand about the "cmd" shell (which is
258 the default on Windows NT) is that it does not do any wildcard
259 expansions of command-line arguments (so wildcards need not be
260 quoted).  It also provides only rudimentary quoting.  The only
261 (useful) quote character is the double quote (").  It can be used to
262 protect spaces in arguments and other special characters.  The
263 Windows NT documentation has almost no description of how the
264 quoting rules are implemented, but here are some general observations
265 based on experiments:  The shell breaks arguments at spaces and
266 passes them to programs in argc/argv.  Doublequotes can be used
267 to prevent arguments with spaces in them from being split up.
268 You can put a double quote in an argument by escaping it with
269 a backslash and enclosing the whole argument within double quotes.
270 The backslash and the pair of double quotes surrounding the
271 argument will be stripped by the shell.
272
273 The file redirection characters "<", ">", and "|" cannot be quoted
274 by double quotes (there are probably more such).  Single quotes
275 will protect those three file redirection characters, but the
276 single quotes don't get stripped by the shell (just to make this
277 type of quoting completely useless).  The caret "^" has also
278 been observed to behave as a quoting character (and doesn't get
279 stripped by the shell also).
280
281 Here are some examples of usage of the "cmd" shell:
282
283 This prints two doublequotes:
284
285     perl -e "print '\"\"' "
286
287 This does the same:
288
289     perl -e "print \"\\\"\\\"\" "
290
291 This prints "bar" and writes "foo" to the file "blurch":
292
293     perl -e "print 'foo'; print STDERR 'bar'" > blurch
294
295 This prints "foo" ("bar" disappears into nowhereland):
296
297     perl -e "print 'foo'; print STDERR 'bar'" 2> nul
298
299 This prints "bar" and writes "foo" into the file "blurch":
300
301     perl -e "print 'foo'; print STDERR 'bar'" 1> blurch
302
303 This pipes "foo" to the "less" pager and prints "bar" on the console:
304
305     perl -e "print 'foo'; print STDERR 'bar'" | less
306
307 This pipes "foo\nbar\n" to the less pager:
308
309     perl -le "print 'foo'; print STDERR 'bar'" 2>&1 | less
310
311 This pipes "foo" to the pager and writes "bar" in the file "blurch":
312
313     perl -e "print 'foo'; print STDERR 'bar'" 2> blurch | less
314
315
316 Discovering the usefulness of the "command.com" shell on Windows95
317 is left as an exercise to the reader :)
318
319 =item Building Extensions
320
321 The Comprehensive Perl Archive Network (CPAN) offers a wealth
322 of extensions, some of which require a C compiler to build.
323 Look in http://www.perl.com/ for more information on CPAN.
324
325 Most extensions (whether they require a C compiler or not) can
326 be built, tested and installed with the standard mantra:
327
328     perl Makefile.PL
329     $MAKE
330     $MAKE test
331     $MAKE install
332
333 where $MAKE stands for NMAKE or DMAKE.  Some extensions may not
334 provide a testsuite (so "$MAKE test" may not do anything, or fail),
335 but most serious ones do.
336
337 If a module implements XSUBs, you will need one of the supported
338 C compilers.  You must make sure you have set up the environment for
339 the compiler for command-line compilation.
340
341 If a module does not build for some reason, look carefully for
342 why it failed, and report problems to the module author.  If
343 it looks like the extension building support is at fault, report
344 that with full details of how the build failed using the perlbug
345 utility.
346
347 =item Win32 Specific Extensions
348
349 A number of extensions specific to the Win32 platform are available
350 from CPAN.  You may find that many of these extensions are meant to
351 be used under the Activeware port of Perl, which used to be the only
352 native port for the Win32 platform.  Since the Activeware port does not
353 have adequate support for Perl's extension building tools, these
354 extensions typically do not support those tools either, and therefore
355 cannot be built using the generic steps shown in the previous section.
356
357 To ensure smooth transitioning of existing code that uses the
358 Activeware port, there is a bundle of Win32 extensions that contains
359 all of the Activeware extensions and most other Win32 extensions from
360 CPAN in source form, along with many added bugfixes, and with MakeMaker
361 support.  This bundle is available at:
362
363    http://www.perl.com/CPAN/authors/id/GSAR/libwin32-0.09.tar.gz
364
365 See the README in that distribution for building and installation
366 instructions.  Look for later versions that may be available at the
367 same location.
368
369 It is expected that authors of Win32 specific extensions will begin
370 distributing their work in MakeMaker compatible form subsequent to
371 the 5.004 release of perl, at which point the need for a dedicated
372 bundle such as the above should diminish.
373
374 =item Running Perl Scripts
375
376 Perl scripts on UNIX use the "#!" (a.k.a "shebang") line to
377 indicate to the OS that it should execute the file using perl.
378 Win32 has no comparable means to indicate arbitrary files are
379 executables.
380
381 Instead, all available methods to execute plain text files on
382 Win32 rely on the file "extension".  There are three methods
383 to use this to execute perl scripts:
384
385 =over 8
386
387 =item 1
388
389 There is a facility called "file extension associations" that will
390 work in Windows NT 4.0.  This can be manipulated via the two
391 commands "assoc" and "ftype" that come standard with Windows NT
392 4.0.  Type "ftype /?" for a complete example of how to set this
393 up for perl scripts (Say what?  You thought Windows NT wasn't
394 perl-ready? :).
395
396 =item 2
397
398 Since file associations don't work everywhere, and there are
399 reportedly bugs with file associations where it does work, the
400 old method of wrapping the perl script to make it look like a
401 regular batch file to the OS, may be used.  The install process
402 makes available the "pl2bat.bat" script which can be used to wrap
403 perl scripts into batch files.  For example:
404
405         pl2bat foo.pl
406
407 will create the file "FOO.BAT".  Note "pl2bat" strips any
408 .pl suffix and adds a .bat suffix to the generated file.
409
410 If you use the 4DOS/NT or similar command shell, note that
411 "pl2bat" uses the "%*" variable in the generated batch file to
412 refer to all the command line arguments, so you may need to make
413 sure that construct works in batch files.  As of this writing,
414 4DOS/NT users will need a "ParameterChar = *" statement in their
415 4NT.INI file, or will need to execute "setdos /p*" in the 4DOS/NT
416 startup file to enable this to work.
417
418 =item 3
419
420 Using "pl2bat" has a few problems:  the file name gets changed,
421 so scripts that rely on C<$0> to find what they must do may not
422 run properly; running "pl2bat" replicates the contents of the
423 original script, and so this process can be maintenance intensive
424 if the originals get updated often.  A different approach that
425 avoids both problems is possible.
426
427 A script called "runperl.bat" is available that can be copied
428 to any filename (along with the .bat suffix).  For example,
429 if you call it "foo.bat", it will run the file "foo" when it is
430 executed.  Since you can run batch files on Win32 platforms simply
431 by typing the name (without the extension), this effectively
432 runs the file "foo", when you type either "foo" or "foo.bat".
433 With this method, "foo.bat" can even be in a different location
434 than the file "foo", as long as "foo" is available somewhere on
435 the PATH.  If your scripts are on a filesystem that allows symbolic
436 links, you can even avoid copying "runperl.bat".
437
438 Here's a diversion:  copy "runperl.bat" to "runperl", and type
439 "runperl".  Explain the observed behavior, or lack thereof. :)
440 Hint: .gnidnats llits er'uoy fi ,"lrepnur" eteled :tniH
441
442 =back
443
444 =item Miscellaneous Things
445
446 A full set of HTML documentation is installed, so you should be
447 able to use it if you have a web browser installed on your
448 system.
449
450 C<perldoc> is also a useful tool for browsing information contained
451 in the documentation, especially in conjunction with a pager
452 like C<less> (recent versions of which have Win32 support).  You may
453 have to set the PAGER environment variable to use a specific pager.
454 "perldoc -f foo" will print information about the perl operator
455 "foo".
456
457 If you find bugs in perl, you can run C<perlbug> to create a
458 bug report (you may have to send it manually if C<perlbug> cannot
459 find a mailer on your system).
460
461 =back
462
463 =head1 BUGS AND CAVEATS
464
465 This port should be considered beta quality software at the present
466 time because some details are still in flux and there may be
467 changes in any of these areas: build process, installation structure,
468 supported utilities/modules, and supported perl functionality.
469 In particular, functionality specific to the Win32 environment may
470 ultimately be supported as either core modules or extensions.  The
471 beta status implies, among other things, that you should be prepared
472 to recompile extensions when binary incompatibilites arise due to
473 changes in the internal structure of the code.
474
475 An effort has been made to ensure that the DLLs produced by the two
476 supported compilers are compatible with each other (despite the
477 best efforts of the compiler vendors).  Extension binaries produced
478 by one compiler should also coexist with a perl binary built by
479 a different compiler.  In order to accomplish this, PERL.DLL provides
480 a layer of runtime code that uses the C Runtime that perl was compiled
481 with.  Extensions which include "perl.h" will transparently access
482 the functions in this layer, thereby ensuring that both perl and
483 extensions use the same runtime functions.
484
485 If you have had prior exposure to Perl on Unix platforms, you will notice
486 this port exhibits behavior different from what is documented.  Most of the
487 differences fall under one of these categories.  We do not consider
488 any of them to be serious limitations (especially when compared to the
489 limited nature of some of the Win32 OSes themselves :)
490
491 =over 8
492
493 =item *
494
495 C<stat()> and C<lstat()> functions may not behave as documented.  They
496 may return values that bear no resemblance to those reported on Unix
497 platforms, and some fields (like the the one for inode) may be completely
498 bogus.
499
500 =item *
501
502 The following functions are currently unavailable: C<fork()>,
503 C<dump()>, C<chown()>, C<link()>, C<symlink()>, C<chroot()>,
504 C<setpgrp()> and related security functions, C<setpriority()>,
505 C<getpriority()>, C<syscall()>, C<fcntl()>, C<getpw*()>,
506 C<msg*()>, C<shm*()>, C<sem*()>, C<alarm()>, C<socketpair()>,
507 C<*netent()>, C<*protoent()>, C<*servent()>, C<*hostent()>,
508 C<getnetby*()>.
509 This list is possibly incomplete.
510
511 =item *
512
513 Various C<socket()> related calls are supported, but they may not
514 behave as on Unix platforms.
515
516 =item *
517
518 The four-argument C<select()> call is only supported on sockets.
519
520 =item *
521
522 The C<ioctl()> call is only supported on sockets (where it provides the
523 functionality of ioctlsocket() in the Winsock API).
524
525 =item *
526
527 Failure to spawn() a subprocess is indicated by setting $? to "255 << 8".
528 C<$?> is set in a way compatible with Unix (i.e. the exitstatus of the
529 subprocess is obtained by "$? >> 8", as described in the documentation).
530
531 =item *
532
533 You can expect problems building modules available on CPAN if you
534 build perl itself with -DUSE_THREADS.  These problems should be resolved
535 as we get closer to 5.005.
536
537 =item *
538
539 C<utime()>, C<times()> and process-related functions may not
540 behave as described in the documentation, and some of the
541 returned values or effects may be bogus.
542
543 =item *
544
545 Signal handling may not behave as on Unix platforms (where it
546 doesn't exactly "behave", either :).  For instance, calling C<die()>
547 or C<exit()> from signal handlers will cause an exception, since most
548 implementations of C<signal()> on Win32 are severely crippled.
549 Thus, signals may work only for simple things like setting a flag
550 variable in the handler.  Using signals under this port should
551 currently be considered unsupported.
552
553 =item *
554
555 File globbing may not behave as on Unix platforms.  In particular,
556 if you don't use perlglob.bat for globbing, it will understand
557 wildcards only in the filename component (and not in the pathname).
558 In other words, something like "print <*/*.pl>" will not print all the
559 perl scripts in all the subdirectories one level under the current one
560 (like it does on UNIX platforms).  perlglob.exe is also dependent on
561 the particular implementation of wildcard expansion in the vendor
562 libraries used to build it (which varies wildly at the present time).
563 Using perlglob.bat (or File::DosGlob) avoids these limitations, but
564 still only provides DOS semantics (read "warts") for globbing.
565
566 =back
567
568 Please send detailed descriptions of any problems and solutions that 
569 you may find to <F<perlbug@perl.com>>, along with the output produced
570 by C<perl -V>.
571
572 =head1 AUTHORS
573
574 =over 4
575
576 Gary Ng E<lt>71564.1743@CompuServe.COME<gt>
577
578 Gurusamy Sarathy E<lt>gsar@umich.eduE<gt>
579
580 Nick Ing-Simmons E<lt>nick@ni-s.u-net.comE<gt>
581
582 =back
583
584 This document is maintained by Gurusamy Sarathy.
585
586 =head1 SEE ALSO
587
588 L<perl>
589
590 =head1 HISTORY
591
592 This port was originally contributed by Gary Ng around 5.003_24,
593 and borrowed from the Hip Communications port that was available
594 at the time.
595
596 Nick Ing-Simmons and Gurusamy Sarathy have made numerous and
597 sundry hacks since then.
598
599 Borland support was added in 5.004_01 (Gurusamy Sarathy).
600
601 Last updated: 3 January 1998
602
603 =cut
604