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 9x/NT/2000/XP on
10       the Intel x86 and Itanium architectures.
11

DESCRIPTION

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

BUGS AND CAVEATS

888       Norton AntiVirus interferes with the build process, particularly if set
889       to "AutoProtect, All Files, when Opened". Unlike large applications the
890       perl build process opens and modifies a lot of files. Having the the
891       AntiVirus scan each and every one slows build the process
892       significantly.  Worse, with PERLIO=stdio the build process fails with
893       peculiar messages as the virus checker interacts badly with
894       miniperl.exe writing configure files (it seems to either catch file
895       part written and treat it as suspicious, or virus checker may have it
896       "locked" in a way which inhibits miniperl updating it). The build does
897       complete with
898
899          set PERLIO=perlio
900
901       but that may be just luck. Other AntiVirus software may have similar
902       issues.
903
904       Some of the built-in functions do not act exactly as documented in
905       perlfunc, and a few are not implemented at all.  To avoid surprises,
906       particularly if you have had prior exposure to Perl in other operating
907       environments or if you intend to write code that will be portable to
908       other environments, see perlport for a reasonably definitive list of
909       these differences.
910
911       Not all extensions available from CPAN may build or work properly in
912       the Win32 environment.  See "Building Extensions".
913
914       Most "socket()" related calls are supported, but they may not behave as
915       on Unix platforms.  See perlport for the full list.  Perl requires
916       Winsock2 to be installed on the system. If you're running Win95, you
917       can download Winsock upgrade from here:
918
919       http://www.microsoft.com/windows95/downloads/contents/WUAdminTools/S_WUNetworkingTools/W95Sockets2/Default.asp
920
921       Later OS versions already include Winsock2 support.
922
923       Signal handling may not behave as on Unix platforms (where it doesn't
924       exactly "behave", either :).  For instance, calling "die()" or "exit()"
925       from signal handlers will cause an exception, since most
926       implementations of "signal()" on Win32 are severely crippled.  Thus,
927       signals may work only for simple things like setting a flag variable in
928       the handler.  Using signals under this port should currently be
929       considered unsupported.
930
931       Please send detailed descriptions of any problems and solutions that
932       you may find to <perlbug@perl.org>, along with the output produced by
933       "perl -V".
934

ACKNOWLEDGEMENTS

936       The use of a camel with the topic of Perl is a trademark of O'Reilly
937       and Associates, Inc. Used with permission.
938

AUTHORS

940       Gary Ng <71564.1743@CompuServe.COM>
941       Gurusamy Sarathy <gsar@activestate.com>
942       Nick Ing-Simmons <nick@ing-simmons.net>
943       Jan Dubois <jand@activestate.com>
944       Steve Hay <steve.hay@uk.radan.com>
945
946       This document is maintained by Jan Dubois.
947

SEE ALSO

949       perl
950

HISTORY

952       This port was originally contributed by Gary Ng around 5.003_24, and
953       borrowed from the Hip Communications port that was available at the
954       time.  Various people have made numerous and sundry hacks since then.
955
956       Borland support was added in 5.004_01 (Gurusamy Sarathy).
957
958       GCC/mingw32 support was added in 5.005 (Nick Ing-Simmons).
959
960       Support for PERL_OBJECT was added in 5.005 (ActiveState Tool Corp).
961
962       Support for fork() emulation was added in 5.6 (ActiveState Tool Corp).
963
964       Win9x support was added in 5.6 (Benjamin Stuhl).
965
966       Support for 64-bit Windows added in 5.8 (ActiveState Corp).
967
968       Last updated: 29 August 2007
969
970
971
972perl v5.12.4                      2011-06-07                      PERLWIN32(1)
Impressum