1PERLWIN32(1)           Perl Programmers Reference Guide           PERLWIN32(1)
2
3
4

NAME

6       perlwin32 - Perl under Windows
7

SYNOPSIS

9       These are instructions for building Perl under Windows 2000 and later.
10

DESCRIPTION

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

BUGS AND CAVEATS

846       Norton AntiVirus interferes with the build process, particularly if set
847       to "AutoProtect, All Files, when Opened". Unlike large applications the
848       perl build process opens and modifies a lot of files. Having the the
849       AntiVirus scan each and every one slows build the process
850       significantly.  Worse, with PERLIO=stdio the build process fails with
851       peculiar messages as the virus checker interacts badly with
852       miniperl.exe writing configure files (it seems to either catch file
853       part written and treat it as suspicious, or virus checker may have it
854       "locked" in a way which inhibits miniperl updating it). The build does
855       complete with
856
857          set PERLIO=perlio
858
859       but that may be just luck. Other AntiVirus software may have similar
860       issues.
861
862       A git GUI shell extension for Windows such as TortoiseGit will cause
863       the build and later "make test" to run much slower since every file is
864       checked for its git status as soon as it is created and/or modified.
865       TortoiseGit doesn't cause any test failures or build problems unlike
866       the antivirus software described above, but it does cause similar
867       slowness. It is suggested to use Task Manager to look for background
868       processes which use high CPU amounts during the building process.
869
870       Some of the built-in functions do not act exactly as documented in
871       perlfunc, and a few are not implemented at all.  To avoid surprises,
872       particularly if you have had prior exposure to Perl in other operating
873       environments or if you intend to write code that will be portable to
874       other environments, see perlport for a reasonably definitive list of
875       these differences.
876
877       Not all extensions available from CPAN may build or work properly in
878       the Windows environment.  See "Building Extensions".
879
880       Most "socket()" related calls are supported, but they may not behave as
881       on Unix platforms.  See perlport for the full list.
882
883       Signal handling may not behave as on Unix platforms (where it doesn't
884       exactly "behave", either :).  For instance, calling "die()" or "exit()"
885       from signal handlers will cause an exception, since most
886       implementations of "signal()" on Windows are severely crippled.  Thus,
887       signals may work only for simple things like setting a flag variable in
888       the handler.  Using signals under this port should currently be
889       considered unsupported.
890
891       Please send detailed descriptions of any problems and solutions that
892       you may find to <perlbug@perl.org>, along with the output produced by
893       "perl -V".
894

ACKNOWLEDGEMENTS

896       The use of a camel with the topic of Perl is a trademark of O'Reilly
897       and Associates, Inc. Used with permission.
898

AUTHORS

900       Gary Ng <71564.1743@CompuServe.COM>
901       Gurusamy Sarathy <gsar@activestate.com>
902       Nick Ing-Simmons <nick@ing-simmons.net>
903       Jan Dubois <jand@activestate.com>
904       Steve Hay <steve.m.hay@googlemail.com>
905
906       This document is maintained by Jan Dubois.
907

SEE ALSO

909       perl
910

HISTORY

912       This port was originally contributed by Gary Ng around 5.003_24, and
913       borrowed from the Hip Communications port that was available at the
914       time.  Various people have made numerous and sundry hacks since then.
915
916       GCC/mingw32 support was added in 5.005 (Nick Ing-Simmons).
917
918       Support for PERL_OBJECT was added in 5.005 (ActiveState Tool Corp).
919
920       Support for fork() emulation was added in 5.6 (ActiveState Tool Corp).
921
922       Win9x support was added in 5.6 (Benjamin Stuhl).
923
924       Support for 64-bit Windows added in 5.8 (ActiveState Corp).
925
926       Last updated: 30 April 2019
927
928
929
930perl v5.30.1                      2019-11-29                      PERLWIN32(1)
Impressum