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-2017 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-2017
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-2017 Express/Community Edition
135           These free versions of Visual C++ 2008-2017 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-2017 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-MSVC141 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.  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 enviroment, 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 dmake "makefile.mk" that will work for all supported compilers.
347           The defaults in the dmake makefile are setup to build using
348           MinGW/gcc.
349
350       ·   Edit the makefile.mk (or Makefile, if you're using nmake) and
351           change the values of INST_DRV and INST_TOP.   You can also enable
352           various build flags.  These are explained in the makefiles.
353
354           Note that it is generally not a good idea to try to build a perl
355           with INST_DRV and INST_TOP set to a path that already exists from a
356           previous build.  In particular, this may cause problems with the
357           lib/ExtUtils/t/Embed.t test, which attempts to build a test program
358           and may end up building against the installed perl's lib/CORE
359           directory rather than the one being tested.
360
361           You will have to make sure that CCTYPE is set correctly and that
362           CCHOME points to wherever you installed your compiler.
363
364           If building with the cross-compiler provided by mingw-w64.org
365           you'll need to uncomment the line that sets GCCCROSS in the
366           makefile.mk. Do this only if it's the cross-compiler - ie only if
367           the bin folder doesn't contain a gcc.exe. (The cross-compiler does
368           not provide a gcc.exe, g++.exe, ar.exe, etc. Instead, all of these
369           executables are prefixed with 'x86_64-w64-mingw32-'.)
370
371           The default value for CCHOME in the makefiles for Visual C++ may
372           not be correct for some versions.  Make sure the default exists and
373           is valid.
374
375           You may also need to comment out the "DELAYLOAD = ..." line in the
376           Makefile if you're using VC++ 6.0 without the latest service pack
377           and the linker reports an internal error.
378
379           If you want build some core extensions statically into perl's dll,
380           specify them in the STATIC_EXT macro.
381
382           NOTE: The USE_64_BIT_INT build option is not supported with the
383           32-bit Visual C++ 6.0 compiler.
384
385           Be sure to read the instructions near the top of the makefiles
386           carefully.
387
388       ·   Type "dmake" (or "nmake" if you are using that make).
389
390           This should build everything.  Specifically, it will create
391           perl.exe, perl528.dll at the perl toplevel, and various other
392           extension dll's under the lib\auto directory.  If the build fails
393           for any reason, make sure you have done the previous steps
394           correctly.
395
396           To try dmake's parallel mode, type "dmake -P2", where 2, is the
397           maximum number of parallel jobs you want to run. A number of things
398           in the build process will run in parallel, but there are
399           serialization points where you will see just 1 CPU maxed out. This
400           is normal.
401
402           If you are advanced enough with building C code, here is a
403           suggestion to speed up building perl, and the later "make test".
404           Try to keep your PATH enviromental variable with the least number
405           of folders possible (remember to keep your C compiler's folders
406           there). "C:\WINDOWS\system32" or "C:\WINNT\system32" depending on
407           your OS version should be first folder in PATH, since "cmd.exe" is
408           the most commonly launched program during the build and later
409           testing.
410
411   Testing Perl on Windows
412       Type "dmake test" (or "nmake test").  This will run most of the tests
413       from the testsuite (many tests will be skipped).
414
415       There should be no test failures.
416
417       If you build with Visual C++ 2013 then three tests currently may fail
418       with Daylight Saving Time related problems: t/io/fs.t,
419       cpan/HTTP-Tiny/t/110_mirror.t and lib/File/Copy.t. The failures are
420       caused by bugs in the CRT in VC++ 2013 which are fixed in VC++2015 and
421       later, as explained by Microsoft here:
422       <https://connect.microsoft.com/VisualStudio/feedback/details/811534/utime-sometimes-fails-to-set-the-correct-file-times-in-visual-c-2013>.
423       In the meantime, if you need fixed "stat" and "utime" functions then
424       have a look at the CPAN distribution Win32::UTCFileTime.
425
426       If you build with certain versions (e.g. 4.8.1) of gcc from
427       www.mingw.org then ext/POSIX/t/time.t may fail test 17 due to a known
428       bug in those gcc builds: see
429       <http://sourceforge.net/p/mingw/bugs/2152/>.
430
431       Some test failures may occur if you use a command shell other than the
432       native "cmd.exe", or if you are building from a path that contains
433       spaces.  So don't do that.
434
435       If you are running the tests from a emacs shell window, you may see
436       failures in op/stat.t.  Run "dmake test-notty" in that case.
437
438       Furthermore, you should make sure that during "make test" you do not
439       have any GNU tool packages in your path: some toolkits like Unixutils
440       include some tools ("type" for instance) which override the Windows
441       ones and makes tests fail. Remove them from your path while testing to
442       avoid these errors.
443
444       Please report any other failures as described under "BUGS AND CAVEATS".
445
446   Installation of Perl on Windows
447       Type "dmake install" (or "nmake install").  This will put the newly
448       built perl and the libraries under whatever "INST_TOP" points to in the
449       Makefile.  It will also install the pod documentation under
450       "$INST_TOP\$INST_VER\lib\pod" and HTML versions of the same under
451       "$INST_TOP\$INST_VER\lib\pod\html".
452
453       To use the Perl you just installed you will need to add a new entry to
454       your PATH environment variable: "$INST_TOP\bin", e.g.
455
456           set PATH=c:\perl\bin;%PATH%
457
458       If you opted to uncomment "INST_VER" and "INST_ARCH" in the makefile
459       then the installation structure is a little more complicated and you
460       will need to add two new PATH components instead:
461       "$INST_TOP\$INST_VER\bin" and "$INST_TOP\$INST_VER\bin\$ARCHNAME", e.g.
462
463           set PATH=c:\perl\5.6.0\bin;c:\perl\5.6.0\bin\MSWin32-x86;%PATH%
464
465   Usage Hints for Perl on Windows
466       Environment Variables
467           The installation paths that you set during the build get compiled
468           into perl, so you don't have to do anything additional to start
469           using that perl (except add its location to your PATH variable).
470
471           If you put extensions in unusual places, you can set PERL5LIB to a
472           list of paths separated by semicolons where you want perl to look
473           for libraries.  Look for descriptions of other environment
474           variables you can set in perlrun.
475
476           You can also control the shell that perl uses to run system() and
477           backtick commands via PERL5SHELL.  See perlrun.
478
479           Perl does not depend on the registry, but it can look up certain
480           default values if you choose to put them there unless disabled at
481           build time with USE_NO_REGISTRY.  On Perl process start Perl checks
482           if "HKEY_CURRENT_USER\Software\Perl" and
483           "HKEY_LOCAL_MACHINE\Software\Perl" exist.  If the keys exists, they
484           will be checked for remainder of the Perl process's run life for
485           certain entries.  Entries in "HKEY_CURRENT_USER\Software\Perl"
486           override entries in "HKEY_LOCAL_MACHINE\Software\Perl".  One or
487           more of the following entries (of type REG_SZ or REG_EXPAND_SZ) may
488           be set in the keys:
489
490            lib-$]        version-specific standard library path to add to @INC
491            lib           standard library path to add to @INC
492            sitelib-$]    version-specific site library path to add to @INC
493            sitelib       site library path to add to @INC
494            vendorlib-$]  version-specific vendor library path to add to @INC
495            vendorlib     vendor library path to add to @INC
496            PERL*         fallback for all %ENV lookups that begin with "PERL"
497
498           Note the $] in the above is not literal.  Substitute whatever
499           version of perl you want to honor that entry, e.g. 5.6.0.  Paths
500           must be separated with semicolons, as usual on Windows.
501
502       File Globbing
503           By default, perl handles file globbing using the File::Glob
504           extension, which provides portable globbing.
505
506           If you want perl to use globbing that emulates the quirks of DOS
507           filename conventions, you might want to consider using
508           File::DosGlob to override the internal glob() implementation.  See
509           File::DosGlob for details.
510
511       Using perl from the command line
512           If you are accustomed to using perl from various command-line
513           shells found in UNIX environments, you will be less than pleased
514           with what Windows offers by way of a command shell.
515
516           The crucial thing to understand about the Windows environment is
517           that the command line you type in is processed twice before Perl
518           sees it.  First, your command shell (usually CMD.EXE) preprocesses
519           the command line, to handle redirection, environment variable
520           expansion, and location of the executable to run. Then, the perl
521           executable splits the remaining command line into individual
522           arguments, using the C runtime library upon which Perl was built.
523
524           It is particularly important to note that neither the shell nor the
525           C runtime do any wildcard expansions of command-line arguments (so
526           wildcards need not be quoted).  Also, the quoting behaviours of the
527           shell and the C runtime are rudimentary at best (and may, if you
528           are using a non-standard shell, be inconsistent).  The only
529           (useful) quote character is the double quote (").  It can be used
530           to protect spaces and other special characters in arguments.
531
532           The Windows documentation describes the shell parsing rules here:
533           <http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true>
534           and the C runtime parsing rules here:
535           <http://msdn.microsoft.com/en-us/library/17w5ykft%28v=VS.100%29.aspx>.
536
537           Here are some further observations based on experiments: The C
538           runtime breaks arguments at spaces and passes them to programs in
539           argc/argv.  Double quotes can be used to prevent arguments with
540           spaces in them from being split up.  You can put a double quote in
541           an argument by escaping it with a backslash and enclosing the whole
542           argument within double quotes.  The backslash and the pair of
543           double quotes surrounding the argument will be stripped by the C
544           runtime.
545
546           The file redirection characters "<", ">", and "|" can be quoted by
547           double quotes (although there are suggestions that this may not
548           always be true).  Single quotes are not treated as quotes by the
549           shell or the C runtime, they don't get stripped by the shell (just
550           to make this type of quoting completely useless).  The caret "^"
551           has also been observed to behave as a quoting character, but this
552           appears to be a shell feature, and the caret is not stripped from
553           the command line, so Perl still sees it (and the C runtime phase
554           does not treat the caret as a quote character).
555
556           Here are some examples of usage of the "cmd" shell:
557
558           This prints two doublequotes:
559
560               perl -e "print '\"\"' "
561
562           This does the same:
563
564               perl -e "print \"\\\"\\\"\" "
565
566           This prints "bar" and writes "foo" to the file "blurch":
567
568               perl -e "print 'foo'; print STDERR 'bar'" > blurch
569
570           This prints "foo" ("bar" disappears into nowhereland):
571
572               perl -e "print 'foo'; print STDERR 'bar'" 2> nul
573
574           This prints "bar" and writes "foo" into the file "blurch":
575
576               perl -e "print 'foo'; print STDERR 'bar'" 1> blurch
577
578           This pipes "foo" to the "less" pager and prints "bar" on the
579           console:
580
581               perl -e "print 'foo'; print STDERR 'bar'" | less
582
583           This pipes "foo\nbar\n" to the less pager:
584
585               perl -le "print 'foo'; print STDERR 'bar'" 2>&1 | less
586
587           This pipes "foo" to the pager and writes "bar" in the file
588           "blurch":
589
590               perl -e "print 'foo'; print STDERR 'bar'" 2> blurch | less
591
592           Discovering the usefulness of the "command.com" shell on Windows 9x
593           is left as an exercise to the reader :)
594
595           One particularly pernicious problem with the 4NT command shell for
596           Windows is that it (nearly) always treats a % character as
597           indicating that environment variable expansion is needed.  Under
598           this shell, it is therefore important to always double any %
599           characters which you want Perl to see (for example, for hash
600           variables), even when they are quoted.
601
602       Building Extensions
603           The Comprehensive Perl Archive Network (CPAN) offers a wealth of
604           extensions, some of which require a C compiler to build.  Look in
605           <http://www.cpan.org/> for more information on CPAN.
606
607           Note that not all of the extensions available from CPAN may work in
608           the Windows environment; you should check the information at
609           <http://www.cpantesters.org/> before investing too much effort into
610           porting modules that don't readily build.
611
612           Most extensions (whether they require a C compiler or not) can be
613           built, tested and installed with the standard mantra:
614
615               perl Makefile.PL
616               $MAKE
617               $MAKE test
618               $MAKE install
619
620           where $MAKE is whatever 'make' program you have configured perl to
621           use.  Use "perl -V:make" to find out what this is.  Some extensions
622           may not provide a testsuite (so "$MAKE test" may not do anything or
623           fail), but most serious ones do.
624
625           It is important that you use a supported 'make' program, and ensure
626           Config.pm knows about it.  If you don't have nmake, you can either
627           get dmake from the location mentioned earlier or get an old version
628           of nmake reportedly available from:
629
630           <http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/nmake15.exe>
631
632           Another option is to use the make written in Perl, available from
633           CPAN.
634
635           <http://www.cpan.org/modules/by-module/Make/>
636
637           You may also use dmake.  See "Make" above on how to get it.
638
639           Note that MakeMaker actually emits makefiles with different syntax
640           depending on what 'make' it thinks you are using.  Therefore, it is
641           important that one of the following values appears in Config.pm:
642
643               make='nmake'        # MakeMaker emits nmake syntax
644               make='dmake'        # MakeMaker emits dmake syntax
645               any other value     # MakeMaker emits generic make syntax
646                                       (e.g GNU make, or Perl make)
647
648           If the value doesn't match the 'make' program you want to use, edit
649           Config.pm to fix it.
650
651           If a module implements XSUBs, you will need one of the supported C
652           compilers.  You must make sure you have set up the environment for
653           the compiler for command-line compilation before running "perl
654           Makefile.PL" or any invocation of make.
655
656           If a module does not build for some reason, look carefully for why
657           it failed, and report problems to the module author.  If it looks
658           like the extension building support is at fault, report that with
659           full details of how the build failed using the perlbug utility.
660
661       Command-line Wildcard Expansion
662           The default command shells on DOS descendant operating systems
663           (such as they are) usually do not expand wildcard arguments
664           supplied to programs.  They consider it the application's job to
665           handle that.  This is commonly achieved by linking the application
666           (in our case, perl) with startup code that the C runtime libraries
667           usually provide.  However, doing that results in incompatible perl
668           versions (since the behavior of the argv expansion code differs
669           depending on the compiler, and it is even buggy on some compilers).
670           Besides, it may be a source of frustration if you use such a perl
671           binary with an alternate shell that *does* expand wildcards.
672
673           Instead, the following solution works rather well. The nice things
674           about it are 1) you can start using it right away; 2) it is more
675           powerful, because it will do the right thing with a pattern like
676           */*/*.c; 3) you can decide whether you do/don't want to use it; and
677           4) you can extend the method to add any customizations (or even
678           entirely different kinds of wildcard expansion).
679
680            C:\> copy con c:\perl\lib\Wild.pm
681            # Wild.pm - emulate shell @ARGV expansion on shells that don't
682            use File::DosGlob;
683            @ARGV = map {
684                         my @g = File::DosGlob::glob($_) if /[*?]/;
685                         @g ? @g : $_;
686                       } @ARGV;
687            1;
688            ^Z
689            C:\> set PERL5OPT=-MWild
690            C:\> perl -le "for (@ARGV) { print }" */*/perl*.c
691            p4view/perl/perl.c
692            p4view/perl/perlio.c
693            p4view/perl/perly.c
694            perl5.005/win32/perlglob.c
695            perl5.005/win32/perllib.c
696            perl5.005/win32/perlglob.c
697            perl5.005/win32/perllib.c
698            perl5.005/win32/perlglob.c
699            perl5.005/win32/perllib.c
700
701           Note there are two distinct steps there: 1) You'll have to create
702           Wild.pm and put it in your perl lib directory. 2) You'll need to
703           set the PERL5OPT environment variable.  If you want argv expansion
704           to be the default, just set PERL5OPT in your default startup
705           environment.
706
707           If you are using the Visual C compiler, you can get the C runtime's
708           command line wildcard expansion built into perl binary.  The
709           resulting binary will always expand unquoted command lines, which
710           may not be what you want if you use a shell that does that for you.
711           The expansion done is also somewhat less powerful than the approach
712           suggested above.
713
714       Notes on 64-bit Windows
715           Windows .NET Server supports the LLP64 data model on the Intel
716           Itanium architecture.
717
718           The LLP64 data model is different from the LP64 data model that is
719           the norm on 64-bit Unix platforms.  In the former, "int" and "long"
720           are both 32-bit data types, while pointers are 64 bits wide.  In
721           addition, there is a separate 64-bit wide integral type, "__int64".
722           In contrast, the LP64 data model that is pervasive on Unix
723           platforms provides "int" as the 32-bit type, while both the "long"
724           type and pointers are of 64-bit precision.  Note that both models
725           provide for 64-bits of addressability.
726
727           64-bit Windows running on Itanium is capable of running 32-bit x86
728           binaries transparently.  This means that you could use a 32-bit
729           build of Perl on a 64-bit system.  Given this, why would one want
730           to build a 64-bit build of Perl?  Here are some reasons why you
731           would bother:
732
733           ·   A 64-bit native application will run much more efficiently on
734               Itanium hardware.
735
736           ·   There is no 2GB limit on process size.
737
738           ·   Perl automatically provides large file support when built under
739               64-bit Windows.
740
741           ·   Embedding Perl inside a 64-bit application.
742
743   Running Perl Scripts
744       Perl scripts on UNIX use the "#!" (a.k.a "shebang") line to indicate to
745       the OS that it should execute the file using perl.  Windows has no
746       comparable means to indicate arbitrary files are executables.
747
748       Instead, all available methods to execute plain text files on Windows
749       rely on the file "extension".  There are three methods to use this to
750       execute perl scripts:
751
752       1.      There is a facility called "file extension associations".  This
753               can be manipulated via the two commands "assoc" and "ftype"
754               that come standard with Windows.  Type "ftype /?" for a
755               complete example of how to set this up for perl scripts (Say
756               what?  You thought Windows wasn't perl-ready? :).
757
758       2.      Since file associations don't work everywhere, and there are
759               reportedly bugs with file associations where it does work, the
760               old method of wrapping the perl script to make it look like a
761               regular batch file to the OS, may be used.  The install process
762               makes available the "pl2bat.bat" script which can be used to
763               wrap perl scripts into batch files.  For example:
764
765                       pl2bat foo.pl
766
767               will create the file "FOO.BAT".  Note "pl2bat" strips any .pl
768               suffix and adds a .bat suffix to the generated file.
769
770               If you use the 4DOS/NT or similar command shell, note that
771               "pl2bat" uses the "%*" variable in the generated batch file to
772               refer to all the command line arguments, so you may need to
773               make sure that construct works in batch files.  As of this
774               writing, 4DOS/NT users will need a "ParameterChar = *"
775               statement in their 4NT.INI file or will need to execute "setdos
776               /p*" in the 4DOS/NT startup file to enable this to work.
777
778       3.      Using "pl2bat" has a few problems:  the file name gets changed,
779               so scripts that rely on $0 to find what they must do may not
780               run properly; running "pl2bat" replicates the contents of the
781               original script, and so this process can be maintenance
782               intensive if the originals get updated often.  A different
783               approach that avoids both problems is possible.
784
785               A script called "runperl.bat" is available that can be copied
786               to any filename (along with the .bat suffix).  For example, if
787               you call it "foo.bat", it will run the file "foo" when it is
788               executed.  Since you can run batch files on Windows platforms
789               simply by typing the name (without the extension), this
790               effectively runs the file "foo", when you type either "foo" or
791               "foo.bat".  With this method, "foo.bat" can even be in a
792               different location than the file "foo", as long as "foo" is
793               available somewhere on the PATH.  If your scripts are on a
794               filesystem that allows symbolic links, you can even avoid
795               copying "runperl.bat".
796
797               Here's a diversion:  copy "runperl.bat" to "runperl", and type
798               "runperl".  Explain the observed behavior, or lack thereof. :)
799               Hint: .gnidnats llits er'uoy fi ,"lrepnur" eteled :tniH
800
801   Miscellaneous Things
802       A full set of HTML documentation is installed, so you should be able to
803       use it if you have a web browser installed on your system.
804
805       "perldoc" is also a useful tool for browsing information contained in
806       the documentation, especially in conjunction with a pager like "less"
807       (recent versions of which have Windows support).  You may have to set
808       the PAGER environment variable to use a specific pager.  "perldoc -f
809       foo" will print information about the perl operator "foo".
810
811       One common mistake when using this port with a GUI library like "Tk" is
812       assuming that Perl's normal behavior of opening a command-line window
813       will go away.  This isn't the case.  If you want to start a copy of
814       "perl" without opening a command-line window, use the "wperl"
815       executable built during the installation process.  Usage is exactly the
816       same as normal "perl" on Windows, except that options like "-h" don't
817       work (since they need a command-line window to print to).
818
819       If you find bugs in perl, you can run "perlbug" to create a bug report
820       (you may have to send it manually if "perlbug" cannot find a mailer on
821       your system).
822

BUGS AND CAVEATS

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

ACKNOWLEDGEMENTS

874       The use of a camel with the topic of Perl is a trademark of O'Reilly
875       and Associates, Inc. Used with permission.
876

AUTHORS

878       Gary Ng <71564.1743@CompuServe.COM>
879       Gurusamy Sarathy <gsar@activestate.com>
880       Nick Ing-Simmons <nick@ing-simmons.net>
881       Jan Dubois <jand@activestate.com>
882       Steve Hay <steve.m.hay@googlemail.com>
883
884       This document is maintained by Jan Dubois.
885

SEE ALSO

887       perl
888

HISTORY

890       This port was originally contributed by Gary Ng around 5.003_24, and
891       borrowed from the Hip Communications port that was available at the
892       time.  Various people have made numerous and sundry hacks since then.
893
894       GCC/mingw32 support was added in 5.005 (Nick Ing-Simmons).
895
896       Support for PERL_OBJECT was added in 5.005 (ActiveState Tool Corp).
897
898       Support for fork() emulation was added in 5.6 (ActiveState Tool Corp).
899
900       Win9x support was added in 5.6 (Benjamin Stuhl).
901
902       Support for 64-bit Windows added in 5.8 (ActiveState Corp).
903
904       Last updated: 23 May 2018
905
906
907
908perl v5.28.2                      2018-11-01                      PERLWIN32(1)
Impressum