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