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