This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove full stop in the 'try' feature heading
[perl5.git] / README.win32
1 # vim: syntax=pod
2
3 If you read this file _as_is_, just ignore the funny characters you
4 see. It is written in the POD format (see pod/perlpod.pod) which is
5 specially designed to be readable as is.
6
7 =head1 NAME
8
9 perlwin32 - Perl under Windows
10
11 =head1 SYNOPSIS
12
13 These are instructions for building Perl under Windows 7 and later.
14
15 =head1 DESCRIPTION
16
17 Before you start, you should glance through the README file
18 found in the top-level directory to which the Perl distribution
19 was extracted.  Make sure you read and understand the terms under
20 which this software is being distributed.
21
22 Also make sure you read L</BUGS AND CAVEATS> below for the
23 known limitations of this port.
24
25 The INSTALL file in the perl top-level has much information that is
26 only relevant to people building Perl on Unix-like systems.  In
27 particular, you can safely ignore any information that talks about
28 "Configure".
29
30 You may also want to look at one other option for building a perl that
31 will work on Windows: the README.cygwin file, which give a different
32 set of rules to build a perl for Windows.  This method will probably
33 enable you to build a more Unix-compatible perl, but you will also
34 need to download and use various other build-time and run-time support
35 software described in that file.
36
37 This set of instructions is meant to describe a so-called "native"
38 port of Perl to the Windows platform.  This includes both 32-bit and
39 64-bit Windows operating systems.  The resulting Perl requires no
40 additional software to run (other than what came with your operating
41 system).  Currently, this port is capable of using one of the
42 following compilers on the Intel x86 and x86_64 architectures:
43
44       Microsoft Visual C++    version 12.0 or later
45       Intel C++ Compiler      (experimental)
46       Gcc by mingw.org        gcc version 3.4.5-5.3.0
47       Gcc by mingw-w64.org    gcc version 4.4.3 or later
48
49 Note that the last two of these are actually competing projects both
50 delivering complete gcc toolchain for MS Windows:
51
52 =over 4
53
54 =item L<https://osdn.net/projects/mingw/>
55
56 Delivers gcc toolchain building 32-bit executables (which can be used both 32 and 64 bit Windows platforms)
57
58 =item L<http://mingw-w64.org>
59
60 Delivers gcc toolchain targeting both 64-bit Windows and 32-bit Windows
61 platforms (despite the project name "mingw-w64" they are not only 64-bit
62 oriented). They deliver the native gcc compilers and cross-compilers
63 that are also supported by perl's makefile.
64
65 =back
66
67 The Microsoft Visual C++ compilers are also now being given away free. They
68 are available as "Visual C++ 2013-2022 Community Edition" and are the same
69 compilers that ship with "Visual C++ 2013-2022 Professional".
70
71 Visual C++ 2013 is capable of B<targeting> XP and Windows Server 2003 but the
72 build host requirement is Windows 7/Windows Server 2012. For more details see
73 https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2013-compatibility-vs
74 and
75 https://docs.microsoft.com/en-us/visualstudio/productinfo/vs2013-sysrequirements-vs
76
77 The MinGW64 compiler is available at L<http://mingw-w64.org>.
78 The latter is actually a cross-compiler targeting Win64. There's also a trimmed
79 down compiler (no java, or gfortran) suitable for building perl available at:
80 L<http://strawberryperl.com/package/kmx/64_gcctoolchain/>
81
82 NOTE: If you're using a 32-bit compiler to build perl on a 64-bit Windows
83 operating system, then you should set the WIN64 environment variable to "undef".
84 Also, the trimmed down compiler only passes tests when USE_ITHREADS *= define
85 (as opposed to undef) and when the CFG *= Debug line is commented out.
86
87 This port fully supports MakeMaker (the set of modules that
88 is used to build extensions to perl).  Therefore, you should be
89 able to build and install most extensions found in the CPAN sites.
90 See L</Usage Hints for Perl on Windows> below for general hints about this.
91
92 =head2 Setting Up Perl on Windows
93
94 =over 4
95
96 =item Make
97
98 You need a "make" program to build the sources.  If you are using
99 Visual C++, you can use nmake supplied with Visual C++.
100 You may also use gmake instead of nmake.  Builds using gcc need
101 gmake. nmake is not supported for gcc builds.  Parallel building is only
102 supported with gmake, not nmake.
103
104 =item Command Shell
105
106 Use the default "cmd" shell that comes with Windows.  Some versions of the
107 popular 4DOS/NT shell have incompatibilities that may cause you trouble.
108 If the build fails under that shell, try building again with the cmd
109 shell.
110
111 Make sure the path to the build directory does not contain spaces.  The
112 build usually works in this circumstance, but some tests will fail.
113
114 =item Microsoft Visual C++
115
116 The nmake that comes with Visual C++ will suffice for building. Visual C++
117 requires that certain things be set up in the console before Visual C++ will
118 successfully run. To make a console box be able to run the C compiler, you will
119 need to beforehand, run C<vcvarsall.bat x86> to compile for x86-32 and for
120 x86-64 C<vcvarsall.bat amd64>. On a typical install of a Microsoft C++
121 compiler product, these batch files will already be in your C<PATH>
122 environment variable so you may just type them without an absolute path into
123 your console. If you need to find the absolute path to the batch file, it is
124 usually found somewhere like
125 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC.
126 With some newer Microsoft C products (released after ~2004), the installer will
127 put a shortcut in the start menu to launch a new console window with the
128 console already set up for your target architecture (x86-32 or x86-64 or IA64).
129 With the newer compilers, you may also use the older batch files if you choose
130 so.
131
132 =item Microsoft Visual C++ 2013-2022 Community Edition
133
134 These free versions of Visual C++ 2013-2022 Professional contain the same
135 compilers and linkers that ship with the full versions, and also contain
136 everything necessary to build Perl.
137
138 These packages can be downloaded by searching in the Download Center at
139 L<https://www.microsoft.com/downloads/search.aspx?displaylang=en>.  (Providing exact
140 links to these packages has proven a pointless task because the links keep on
141 changing so often.)
142
143 Install Visual C++ 2013-2022 Community, then setup your environment
144 using, e.g.
145
146  C:\Program Files\Microsoft Visual Studio 12.0\Common7\Tools\vsvars32.bat
147
148 (assuming the default installation location was chosen).
149
150 Perl should now build using the win32/Makefile.  You will need to edit that
151 file to set CCTYPE to one of MSVC120-MSVC142 first.
152
153 =item GCC
154
155 Perl can be compiled with gcc from MinGW (version 3.4.5 or later) or from
156 MinGW64 (version 4.4.3 or later).  It can be downloaded here:
157
158 L<https://osdn.net/projects/mingw/>
159 L<http://www.mingw-w64.org/>
160
161 You also need gmake. Usually it comes with MinGW but its executable may have
162 a different name, such as mingw32-make.exe.
163
164 Note that the MinGW build currently fails with version 6.3.0 or later.
165
166 Note also that the C++ mode build currently fails with MinGW 3.4.5 and 4.7.2
167 or later, and with MinGW64 64-bit 6.3.0 or later.
168
169 =item Intel C++ Compiler
170
171 Experimental support for using Intel C++ Compiler has been added. Edit
172 win32/Makefile and pick the correct CCTYPE for the Visual C that Intel C was
173 installed into. Also uncomment __ICC to enable Intel C on Visual C support.
174 To set up the build environment, from the Start Menu run
175 IA-32 Visual Studio 20__ mode or Intel 64 Visual Studio 20__ mode as
176 appropriate. Then run nmake as usually in that prompt box.
177
178 Only Intel C++ Compiler v12.1 has been tested. Other versions probably will
179 work. Using Intel C++ Compiler instead of Visual C has the benefit of C99
180 compatibility which is needed by some CPAN XS modules, while maintaining
181 compatibility with Visual C object code and Visual C debugging infrastructure
182 unlike GCC.
183
184 =back
185
186 =head2 Building
187
188 =over 4
189
190 =item *
191
192 Make sure you are in the "win32" subdirectory under the perl toplevel.
193 This directory contains a "Makefile" that will work with
194 versions of nmake that come with Visual C++, and
195 a GNU make "GNUmakefile" that will work for all supported compilers.
196 The defaults in the gmake makefile are setup to build using MinGW/gcc.
197
198 =item *
199
200 Edit the GNUmakefile (or Makefile, if you're using nmake) and change the values
201 of INST_DRV and INST_TOP. You can also enable various build flags. These are
202 explained in the makefiles.
203
204 Note that it is generally not a good idea to try to build a perl with
205 INST_DRV and INST_TOP set to a path that already exists from a previous
206 build.  In particular, this may cause problems with the
207 lib/ExtUtils/t/Embed.t test, which attempts to build a test program and
208 may end up building against the installed perl's lib/CORE directory rather
209 than the one being tested.
210
211 You will have to make sure that CCTYPE is set correctly and that
212 CCHOME points to wherever you installed your compiler.  For GCC this
213 should be the directory that contains the F<bin>, F<include> and
214 F<lib> directories.
215
216 If building with the cross-compiler provided by
217 mingw-w64.org you'll need to uncomment the line that sets
218 GCCCROSS in the GNUmakefile. Do this only if it's the cross-compiler - ie
219 only if the bin folder doesn't contain a gcc.exe. (The cross-compiler
220 does not provide a gcc.exe, g++.exe, ar.exe, etc. Instead, all of these
221 executables are prefixed with 'x86_64-w64-mingw32-'.)
222
223 The default value for CCHOME in the makefiles for Visual C++
224 may not be correct for some versions.  Make sure the default exists
225 and is valid.
226
227 If you want build some core extensions statically into perl's dll, specify
228 them in the STATIC_EXT macro.
229
230 Be sure to read the instructions near the top of the makefiles carefully.
231
232 =item *
233
234 Type "gmake" (or "nmake" if you are using that make).
235
236 This should build everything.  Specifically, it will create perl.exe,
237 perl537.dll at the perl toplevel, and various other extension dll's
238 under the lib\auto directory.  If the build fails for any reason, make
239 sure you have done the previous steps correctly.
240
241 To try gmake's parallel mode, type "gmake -j2", where 2, is the maximum number
242 of parallel jobs you want to run. A number of things in the build process will
243 run in parallel, but there are serialization points where you will see just 1
244 CPU maxed out. This is normal.
245
246 If you are advanced enough with building C code, here is a suggestion to speed
247 up building perl, and the later C<make test>. Try to keep your PATH environmental
248 variable with the least number of folders possible (remember to keep your C
249 compiler's folders there). C<C:\WINDOWS\system32> or C<C:\WINNT\system32>
250 depending on your OS version should be first folder in PATH, since "cmd.exe"
251 is the most commonly launched program during the build and later testing.
252
253 =back
254
255 =head2 Testing Perl on Windows
256
257 Type "gmake test" (or "nmake test").  This will run most
258 of the tests from the testsuite (many tests will be skipped).
259
260 There should be no test failures.
261
262 If you build with Visual C++ 2013 then three tests currently may fail with
263 Daylight Saving Time related problems: F<t/io/fs.t>,
264 F<cpan/HTTP-Tiny/t/110_mirror.t> and F<lib/File/Copy.t>. The failures are
265 caused by bugs in the CRT in VC++ 2013 which are fixed in VC++2015 and
266 later, as explained by Microsoft here:
267 L<https://connect.microsoft.com/VisualStudio/feedback/details/811534/utime-sometimes-fails-to-set-the-correct-file-times-in-visual-c-2013>. In the meantime,
268 if you need fixed C<stat> and C<utime> functions then have a look at the
269 CPAN distribution Win32::UTCFileTime.
270
271 If you build with Visual C++ 2015 or later then F<ext/XS-APItest/t/locale.t>
272 may crash (after all its tests have passed). This is due to a regression in the
273 Universal CRT introduced in the Windows 10 April 2018 Update, and will be fixed
274 in the May 2019 Update, as explained here: L<https://developercommunity.visualstudio.com/content/problem/519486/setlocalelc-numeric-iso-latin-16-fails-then-succee.html>.
275
276 If you build with certain versions (e.g. 4.8.1) of gcc from mingw then
277 F<ext/POSIX/t/time.t> may fail test 17 due to a known bug in those gcc builds:
278 see L<https://sourceforge.net/p/mingw/bugs/2152/>.
279
280 Some test failures may occur if you use a command shell other than the
281 native "cmd.exe", or if you are building from a path that contains
282 spaces.  So don't do that.
283
284 If you are running the tests from a emacs shell window, you may see
285 failures in op/stat.t.  Run "gmake test-notty" in that case.
286
287 Furthermore, you should make sure that during C<make test> you do not
288 have any GNU tool packages in your path: some toolkits like Unixutils
289 include some tools (C<type> for instance) which override the Windows
290 ones and makes tests fail. Remove them from your path while testing to
291 avoid these errors.
292
293 To see the output of specific failing tests run the harness from the t
294 directory:
295
296   # assuming you're starting from the win32 directory
297   cd ..\win32
298   .\perl harness <list of tests>
299
300 Please report any other failures as described under L</BUGS AND CAVEATS>.
301
302 =head2 Installation of Perl on Windows
303
304 Type "gmake install" ("nmake install").  This will
305 put the newly built perl and the libraries under whatever C<INST_TOP>
306 points to in the Makefile.  It will also install the pod documentation
307 under C<$INST_TOP\$INST_VER\lib\pod> and HTML versions of the same
308 under C<$INST_TOP\$INST_VER\lib\pod\html>.
309
310 To use the Perl you just installed you will need to add a new entry to
311 your PATH environment variable: C<$INST_TOP\bin>, e.g.
312
313     set PATH=c:\perl\bin;%PATH%
314
315 If you opted to uncomment C<INST_VER> and C<INST_ARCH> in the makefile
316 then the installation structure is a little more complicated and you will
317 need to add two new PATH components instead: C<$INST_TOP\$INST_VER\bin> and
318 C<$INST_TOP\$INST_VER\bin\$ARCHNAME>, e.g.
319
320     set PATH=c:\perl\5.6.0\bin;c:\perl\5.6.0\bin\MSWin32-x86;%PATH%
321
322 =head2 Usage Hints for Perl on Windows
323
324 =over 4
325
326 =item Environment Variables
327
328 The installation paths that you set during the build get compiled
329 into perl, so you don't have to do anything additional to start
330 using that perl (except add its location to your PATH variable).
331
332 If you put extensions in unusual places, you can set PERL5LIB
333 to a list of paths separated by semicolons where you want perl
334 to look for libraries.  Look for descriptions of other environment
335 variables you can set in L<perlrun>.
336
337 You can also control the shell that perl uses to run system() and
338 backtick commands via PERL5SHELL.  See L<perlrun>.
339
340 Perl does not depend on the registry, but it can look up certain default
341 values if you choose to put them there unless disabled at build time with
342 USE_NO_REGISTRY.  On Perl process start Perl checks if
343 C<HKEY_CURRENT_USER\Software\Perl> and C<HKEY_LOCAL_MACHINE\Software\Perl>
344 exist.  If the keys exists, they will be checked for remainder of the Perl
345 process's run life for certain entries.  Entries in
346 C<HKEY_CURRENT_USER\Software\Perl> override entries in
347 C<HKEY_LOCAL_MACHINE\Software\Perl>.  One or more of the following entries
348 (of type REG_SZ or REG_EXPAND_SZ) may be set in the keys:
349
350  lib-$]        version-specific standard library path to add to @INC
351  lib           standard library path to add to @INC
352  sitelib-$]    version-specific site library path to add to @INC
353  sitelib       site library path to add to @INC
354  vendorlib-$]  version-specific vendor library path to add to @INC
355  vendorlib     vendor library path to add to @INC
356  PERL*         fallback for all %ENV lookups that begin with "PERL"
357
358 Note the C<$]> in the above is not literal.  Substitute whatever version
359 of perl you want to honor that entry, e.g. C<5.6.0>.  Paths must be
360 separated with semicolons, as usual on Windows.
361
362 =item File Globbing
363
364 By default, perl handles file globbing using the File::Glob extension,
365 which provides portable globbing.
366
367 If you want perl to use globbing that emulates the quirks of DOS
368 filename conventions, you might want to consider using File::DosGlob
369 to override the internal glob() implementation.  See L<File::DosGlob> for
370 details.
371
372 =item Using perl from the command line
373
374 If you are accustomed to using perl from various command-line
375 shells found in UNIX environments, you will be less than pleased
376 with what Windows offers by way of a command shell.
377
378 The crucial thing to understand about the Windows environment is that
379 the command line you type in is processed twice before Perl sees it.
380 First, your command shell (usually CMD.EXE) preprocesses the command
381 line, to handle redirection, environment variable expansion, and
382 location of the executable to run. Then, the perl executable splits
383 the remaining command line into individual arguments, using the
384 C runtime library upon which Perl was built.
385
386 It is particularly important to note that neither the shell nor the C
387 runtime do any wildcard expansions of command-line arguments (so
388 wildcards need not be quoted).  Also, the quoting behaviours of the
389 shell and the C runtime are rudimentary at best (and may, if you are
390 using a non-standard shell, be inconsistent).  The only (useful) quote
391 character is the double quote (").  It can be used to protect spaces
392 and other special characters in arguments.
393
394 The Windows documentation describes the shell parsing rules here:
395 L<https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/cmd>
396 and the C runtime parsing rules here:
397 L<https://msdn.microsoft.com/en-us/library/17w5ykft%28v=VS.100%29.aspx>.
398
399 Here are some further observations based on experiments: The C runtime
400 breaks arguments at spaces and passes them to programs in argc/argv.
401 Double quotes can be used to prevent arguments with spaces in them from
402 being split up.  You can put a double quote in an argument by escaping
403 it with a backslash and enclosing the whole argument within double quotes.
404 The backslash and the pair of double quotes surrounding the argument will
405 be stripped by the C runtime.
406
407 The file redirection characters "E<lt>", "E<gt>", and "|" can be quoted by
408 double quotes (although there are suggestions that this may not always
409 be true).  Single quotes are not treated as quotes by the shell or
410 the C runtime, they don't get stripped by the shell (just to make
411 this type of quoting completely useless).  The caret "^" has also
412 been observed to behave as a quoting character, but this appears
413 to be a shell feature, and the caret is not stripped from the command
414 line, so Perl still sees it (and the C runtime phase does not treat
415 the caret as a quote character).
416
417 Here are some examples of usage of the "cmd" shell:
418
419 This prints two doublequotes:
420
421     perl -e "print '\"\"' "
422
423 This does the same:
424
425     perl -e "print \"\\\"\\\"\" "
426
427 This prints "bar" and writes "foo" to the file "blurch":
428
429     perl -e "print 'foo'; print STDERR 'bar'" > blurch
430
431 This prints "foo" ("bar" disappears into nowhereland):
432
433     perl -e "print 'foo'; print STDERR 'bar'" 2> nul
434
435 This prints "bar" and writes "foo" into the file "blurch":
436
437     perl -e "print 'foo'; print STDERR 'bar'" 1> blurch
438
439 This pipes "foo" to the "less" pager and prints "bar" on the console:
440
441     perl -e "print 'foo'; print STDERR 'bar'" | less
442
443 This pipes "foo\nbar\n" to the less pager:
444
445     perl -le "print 'foo'; print STDERR 'bar'" 2>&1 | less
446
447 This pipes "foo" to the pager and writes "bar" in the file "blurch":
448
449     perl -e "print 'foo'; print STDERR 'bar'" 2> blurch | less
450
451
452 Discovering the usefulness of the "command.com" shell on Windows 9x
453 is left as an exercise to the reader :)
454
455 One particularly pernicious problem with the 4NT command shell for
456 Windows is that it (nearly) always treats a % character as indicating
457 that environment variable expansion is needed.  Under this shell, it is
458 therefore important to always double any % characters which you want
459 Perl to see (for example, for hash variables), even when they are
460 quoted.
461
462 =item Building Extensions
463
464 The Comprehensive Perl Archive Network (CPAN) offers a wealth
465 of extensions, some of which require a C compiler to build.
466 Look in L<https://www.cpan.org/> for more information on CPAN.
467
468 Note that not all of the extensions available from CPAN may work
469 in the Windows environment; you should check the information at
470 L<https://www.cpantesters.org/> before investing too much effort into
471 porting modules that don't readily build.
472
473 Most extensions (whether they require a C compiler or not) can
474 be built, tested and installed with the standard mantra:
475
476     perl Makefile.PL
477     $MAKE
478     $MAKE test
479     $MAKE install
480
481 where $MAKE is whatever 'make' program you have configured perl to
482 use.  Use "perl -V:make" to find out what this is.  Some extensions
483 may not provide a testsuite (so "$MAKE test" may not do anything or
484 fail), but most serious ones do.
485
486 It is important that you use a supported 'make' program, and
487 ensure Config.pm knows about it.
488
489 Note that MakeMaker actually emits makefiles with different syntax
490 depending on what 'make' it thinks you are using.  Therefore, it is
491 important that one of the following values appears in Config.pm:
492
493     make='nmake'        # MakeMaker emits nmake syntax
494     any other value     # MakeMaker emits generic make syntax
495                             (e.g GNU make, or Perl make)
496
497 If the value doesn't match the 'make' program you want to use,
498 edit Config.pm to fix it.
499
500 If a module implements XSUBs, you will need one of the supported
501 C compilers.  You must make sure you have set up the environment for
502 the compiler for command-line compilation before running C<perl Makefile.PL>
503 or any invocation of make.
504
505 If a module does not build for some reason, look carefully for
506 why it failed, and report problems to the module author.  If
507 it looks like the extension building support is at fault, report
508 that with full details of how the build failed using the GitHub
509 issue tracker at L<https://github.com/Perl/perl5/issues>.
510
511 =item Command-line Wildcard Expansion
512
513 The default command shells on DOS descendant operating systems (such
514 as they are) usually do not expand wildcard arguments supplied to
515 programs.  They consider it the application's job to handle that.
516 This is commonly achieved by linking the application (in our case,
517 perl) with startup code that the C runtime libraries usually provide.
518 However, doing that results in incompatible perl versions (since the
519 behavior of the argv expansion code differs depending on the
520 compiler, and it is even buggy on some compilers).  Besides, it may
521 be a source of frustration if you use such a perl binary with an
522 alternate shell that *does* expand wildcards.
523
524 Instead, the following solution works rather well. The nice things
525 about it are 1) you can start using it right away; 2) it is more
526 powerful, because it will do the right thing with a pattern like
527 */*/*.c; 3) you can decide whether you do/don't want to use it; and
528 4) you can extend the method to add any customizations (or even
529 entirely different kinds of wildcard expansion).
530
531  C:\> copy con c:\perl\lib\Wild.pm
532  # Wild.pm - emulate shell @ARGV expansion on shells that don't
533  use File::DosGlob;
534  @ARGV = map {
535               my @g = File::DosGlob::glob($_) if /[*?]/;
536               @g ? @g : $_;
537             } @ARGV;
538  1;
539  ^Z
540  C:\> set PERL5OPT=-MWild
541  C:\> perl -le "for (@ARGV) { print }" */*/perl*.c
542  p4view/perl/perl.c
543  p4view/perl/perlio.c
544  p4view/perl/perly.c
545  perl5.005/win32/perlglob.c
546  perl5.005/win32/perllib.c
547  perl5.005/win32/perlglob.c
548  perl5.005/win32/perllib.c
549  perl5.005/win32/perlglob.c
550  perl5.005/win32/perllib.c
551
552 Note there are two distinct steps there: 1) You'll have to create
553 Wild.pm and put it in your perl lib directory. 2) You'll need to
554 set the PERL5OPT environment variable.  If you want argv expansion
555 to be the default, just set PERL5OPT in your default startup
556 environment.
557
558 If you are using the Visual C compiler, you can get the C runtime's
559 command line wildcard expansion built into perl binary.  The resulting
560 binary will always expand unquoted command lines, which may not be
561 what you want if you use a shell that does that for you.  The expansion
562 done is also somewhat less powerful than the approach suggested above.
563
564 =item Notes on 64-bit Windows
565
566 Windows .NET Server supports the LLP64 data model on the Intel Itanium
567 architecture.
568
569 The LLP64 data model is different from the LP64 data model that is the
570 norm on 64-bit Unix platforms.  In the former, C<int> and C<long> are
571 both 32-bit data types, while pointers are 64 bits wide.  In addition,
572 there is a separate 64-bit wide integral type, C<__int64>.  In contrast,
573 the LP64 data model that is pervasive on Unix platforms provides C<int>
574 as the 32-bit type, while both the C<long> type and pointers are of
575 64-bit precision.  Note that both models provide for 64-bits of
576 addressability.
577
578 64-bit Windows running on Itanium is capable of running 32-bit x86
579 binaries transparently.  This means that you could use a 32-bit build
580 of Perl on a 64-bit system.  Given this, why would one want to build
581 a 64-bit build of Perl?  Here are some reasons why you would bother:
582
583 =over
584
585 =item *
586
587 A 64-bit native application will run much more efficiently on
588 Itanium hardware.
589
590 =item *
591
592 There is no 2GB limit on process size.
593
594 =item *
595
596 Perl automatically provides large file support when built under
597 64-bit Windows.
598
599 =item *
600
601 Embedding Perl inside a 64-bit application.
602
603 =back
604
605 =back
606
607 =head2 Running Perl Scripts
608
609 Perl scripts on UNIX use the "#!" (a.k.a "shebang") line to
610 indicate to the OS that it should execute the file using perl.
611 Windows has no comparable means to indicate arbitrary files are
612 executables.
613
614 Instead, all available methods to execute plain text files on
615 Windows rely on the file "extension".  There are three methods
616 to use this to execute perl scripts:
617
618 =over 8
619
620 =item 1
621
622 There is a facility called "file extension associations".  This can be
623 manipulated via the two commands "assoc" and "ftype" that come
624 standard with Windows.  Type "ftype /?" for a complete example of how
625 to set this up for perl scripts (Say what?  You thought Windows
626 wasn't perl-ready? :).
627
628 =item 2
629
630 Since file associations don't work everywhere, and there are
631 reportedly bugs with file associations where it does work, the
632 old method of wrapping the perl script to make it look like a
633 regular batch file to the OS, may be used.  The install process
634 makes available the "pl2bat.bat" script which can be used to wrap
635 perl scripts into batch files.  For example:
636
637         pl2bat foo.pl
638
639 will create the file "FOO.BAT".  Note "pl2bat" strips any
640 .pl suffix and adds a .bat suffix to the generated file.
641
642 If you use the 4DOS/NT or similar command shell, note that
643 "pl2bat" uses the "%*" variable in the generated batch file to
644 refer to all the command line arguments, so you may need to make
645 sure that construct works in batch files.  As of this writing,
646 4DOS/NT users will need a "ParameterChar = *" statement in their
647 4NT.INI file or will need to execute "setdos /p*" in the 4DOS/NT
648 startup file to enable this to work.
649
650 =item 3
651
652 Using "pl2bat" has a few problems:  the file name gets changed,
653 so scripts that rely on C<$0> to find what they must do may not
654 run properly; running "pl2bat" replicates the contents of the
655 original script, and so this process can be maintenance intensive
656 if the originals get updated often.  A different approach that
657 avoids both problems is possible.
658
659 A script called "runperl.bat" is available that can be copied
660 to any filename (along with the .bat suffix).  For example,
661 if you call it "foo.bat", it will run the file "foo" when it is
662 executed.  Since you can run batch files on Windows platforms simply
663 by typing the name (without the extension), this effectively
664 runs the file "foo", when you type either "foo" or "foo.bat".
665 With this method, "foo.bat" can even be in a different location
666 than the file "foo", as long as "foo" is available somewhere on
667 the PATH.  If your scripts are on a filesystem that allows symbolic
668 links, you can even avoid copying "runperl.bat".
669
670 Here's a diversion:  copy "runperl.bat" to "runperl", and type
671 "runperl".  Explain the observed behavior, or lack thereof. :)
672 Hint: .gnidnats llits er'uoy fi ,"lrepnur" eteled :tniH
673
674 =back
675
676 =head2 Miscellaneous Things
677
678 A full set of HTML documentation is installed, so you should be
679 able to use it if you have a web browser installed on your
680 system.
681
682 C<perldoc> is also a useful tool for browsing information contained
683 in the documentation, especially in conjunction with a pager
684 like C<less> (recent versions of which have Windows support).  You may
685 have to set the PAGER environment variable to use a specific pager.
686 "perldoc -f foo" will print information about the perl operator
687 "foo".
688
689 One common mistake when using this port with a GUI library like C<Tk>
690 is assuming that Perl's normal behavior of opening a command-line
691 window will go away.  This isn't the case.  If you want to start a copy
692 of C<perl> without opening a command-line window, use the C<wperl>
693 executable built during the installation process.  Usage is exactly
694 the same as normal C<perl> on Windows, except that options like C<-h>
695 don't work (since they need a command-line window to print to).
696
697 If you find bugs in perl, you can report them to
698 L<https://github.com/Perl/perl5/issues>.
699
700 =head1 BUGS AND CAVEATS
701
702 Norton AntiVirus interferes with the build process, particularly if
703 set to "AutoProtect, All Files, when Opened". Unlike large applications
704 the perl build process opens and modifies a lot of files. Having the
705 AntiVirus scan each and every one slows build the process significantly.
706 Worse, with PERLIO=stdio the build process fails with peculiar messages
707 as the virus checker interacts badly with miniperl.exe writing configure
708 files (it seems to either catch file part written and treat it as suspicious,
709 or virus checker may have it "locked" in a way which inhibits miniperl
710 updating it). The build does complete with
711
712    set PERLIO=perlio
713
714 but that may be just luck. Other AntiVirus software may have similar issues.
715
716 A git GUI shell extension for Windows such as TortoiseGit will cause the build
717 and later C<make test> to run much slower since every file is checked for its
718 git status as soon as it is created and/or modified. TortoiseGit doesn't cause
719 any test failures or build problems unlike the antivirus software described
720 above, but it does cause similar slowness. It is suggested to use Task Manager
721 to look for background processes which use high CPU amounts during the building
722 process.
723
724 Some of the built-in functions do not act exactly as documented in
725 L<perlfunc>, and a few are not implemented at all.  To avoid
726 surprises, particularly if you have had prior exposure to Perl
727 in other operating environments or if you intend to write code
728 that will be portable to other environments, see L<perlport>
729 for a reasonably definitive list of these differences.
730
731 Not all extensions available from CPAN may build or work properly
732 in the Windows environment.  See L</"Building Extensions">.
733
734 Most C<socket()> related calls are supported, but they may not
735 behave as on Unix platforms.  See L<perlport> for the full list.
736
737 Signal handling may not behave as on Unix platforms (where it
738 doesn't exactly "behave", either :).  For instance, calling C<die()>
739 or C<exit()> from signal handlers will cause an exception, since most
740 implementations of C<signal()> on Windows are severely crippled.
741 Thus, signals may work only for simple things like setting a flag
742 variable in the handler.  Using signals under this port should
743 currently be considered unsupported.
744
745 Please report detailed descriptions of any problems and solutions that
746 you may find at E<lt>L<https://github.com/Perl/perl5/issues>E<gt>,
747 along with the output produced by C<perl -V>.
748
749 =head1 ACKNOWLEDGEMENTS
750
751 The use of a camel with the topic of Perl is a trademark
752 of O'Reilly and Associates, Inc. Used with permission.
753
754 =head1 AUTHORS
755
756 =over 4
757
758 =item Gary Ng E<lt>71564.1743@CompuServe.COME<gt>
759
760 =item Gurusamy Sarathy E<lt>gsar@activestate.comE<gt>
761
762 =item Nick Ing-Simmons E<lt>nick@ing-simmons.netE<gt>
763
764 =item Jan Dubois E<lt>jand@activestate.comE<gt>
765
766 =item Steve Hay E<lt>steve.m.hay@googlemail.comE<gt>
767
768 =back
769
770 This document is maintained by Jan Dubois.
771
772 =head1 SEE ALSO
773
774 L<perl>
775
776 =head1 HISTORY
777
778 This port was originally contributed by Gary Ng around 5.003_24,
779 and borrowed from the Hip Communications port that was available
780 at the time.  Various people have made numerous and sundry hacks
781 since then.
782
783 GCC/mingw32 support was added in 5.005 (Nick Ing-Simmons).
784
785 Support for PERL_OBJECT was added in 5.005 (ActiveState Tool Corp).
786
787 Support for fork() emulation was added in 5.6 (ActiveState Tool Corp).
788
789 Win9x support was added in 5.6 (Benjamin Stuhl).
790
791 Support for 64-bit Windows added in 5.8 (ActiveState Corp).
792
793 Last updated: 06 October 2021
794
795 =cut