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