Introduced thr->threadsvp and THREADSV() for faster per-thread
[p5sagit/p5-mst-13.2.git] / README.win32
CommitLineData
68dc0745 1If you read this file _as_is_, just ignore the funny characters you
2see. It is written in the POD format (see pod/perlpod.pod) which is
3specially designed to be readable as is.
4
5=head1 NAME
6
5aabfad6 7perlwin32 - Perl under Win32
68dc0745 8
9=head1 SYNOPSIS
10
7bac28a0 11These are instructions for building Perl under Windows NT (versions
3e3baf6d 123.51 or 4.0), using Visual C++ (versions 2.0 through 5.0) or Borland
26618a56 13C++ (version 5.02 or later). Currently, this port is reported to build
14under Windows95 using the 4DOS shell--the default shell that infests
15Windows95 will not work (see below). Note this caveat is only about
3e3baf6d 16B<building> perl. Once built, you should be able to B<use> it on
17either Win32 platform (modulo the problems arising from the inferior
18command shell).
68dc0745 19
20=head1 DESCRIPTION
21
3fe9a6f1 22Before you start, you should glance through the README file
68dc0745 23found in the top-level directory where the Perl distribution
24was extracted. Make sure you read and understand the terms under
25which this software is being distributed.
26
f7c603cb 27Also make sure you read L<BUGS AND CAVEATS> below for the
68dc0745 28known limitations of this port.
29
30The INSTALL file in the perl top-level has much information that is
31only relevant to people building Perl on Unix-like systems. In
32particular, you can safely ignore any information that talks about
33"Configure".
34
7bac28a0 35You may also want to look at two other options for building
36a perl that will work on Windows NT: the README.cygwin32 and
3e3baf6d 37README.os2 files, which each give a different set of rules to build
38a Perl that will work on Win32 platforms. Those two methods will
7bac28a0 39probably enable you to build a more Unix-compatible perl, but you
40will also need to download and use various other build-time and
41run-time support software described in those files.
68dc0745 42
43This set of instructions is meant to describe a so-called "native"
44port of Perl to Win32 platforms. The resulting Perl requires no
45additional software to run (other than what came with your operating
3e3baf6d 46system). Currently, this port is capable of using either the
47Microsoft Visual C++ compiler, or the Borland C++ compiler. The
48ultimate goal is to support the other major compilers that can
49generally be used to build Win32 applications.
5aabfad6 50
51This port currently supports MakeMaker (the set of modules that
52is used to build extensions to perl). Therefore, you should be
53able to build and install most extensions found in the CPAN sites.
c90c0ff4 54See L<Usage Hints> below for general hints about this.
68dc0745 55
56=head2 Setting Up
57
58=over 4
59
3e3baf6d 60=item Command Shell
68dc0745 61
26618a56 62Use the default "cmd" shell that comes with NT. Some versions of the
63popular 4DOS/NT shell have incompatibilities that may cause you trouble.
64If the build fails under that shell, try building again with the cmd
65shell. The Makefile also has known incompatibilites with the "command.com"
66shell that comes with Windows95, so building under Windows95 should
67be considered "unsupported". However, there have been reports of successful
68build attempts using 4DOS/NT version 3.00 under Windows95, using dmake, but
69your mileage may vary.
70
71The surest way to build it is on WindowsNT, using the cmd shell.
68dc0745 72
3e3baf6d 73=item Borland C++
74
75If you are using the Borland compiler, you will need dmake, a freely
76available make that has very nice macro features and parallelability.
77(The make that Borland supplies is seriously crippled, and will not
26618a56 78work for MakeMaker builds.)
79
80A port of dmake for win32 platforms is available from:
3e3baf6d 81
26618a56 82 http://www-personal.umich.edu/~gsar/dmake-4.1-win32.zip
83
84Fetch and install dmake somewhere on your path (follow the instructions
85in the README.NOW file).
3e3baf6d 86
87=item Microsoft Visual C++
68dc0745 88
3e3baf6d 89The NMAKE that comes with Visual C++ will suffice for building.
7bac28a0 90If you did not choose to always initialize the Visual C++ compilation
91environment variables when you installed Visual C++ on your system, you
92will need to run the VCVARS32.BAT file usually found somewhere like
93C:\MSDEV4.2\BIN. This will set your build environment.
68dc0745 94
26618a56 95You can also use dmake to build using Visual C++, provided:
96you set OSRELEASE to "microsft" (or whatever the directory name
97under which the Visual C dmake configuration lives) in your environment,
98and edit win32/config.vc to change "make=nmake" into "make=dmake". The
99latter step is only essential if you want to use dmake as your default
100make for building extensions using MakeMaker.
3e3baf6d 101
102=item Permissions
68dc0745 103
104Depending on how you extracted the distribution, you have to make sure
7bac28a0 105some of the files are writable by you. The easiest way to make sure of
68dc0745 106this is to execute:
107
108 attrib -R *.* /S
109
110from the perl toplevel directory. You don't I<have> to do this if you
111used the right tools to extract the files in the standard distribution,
112but it doesn't hurt to do so.
113
114=back
115
137443ea 116=head2 Building
68dc0745 117
118=over 4
119
120=item *
121
68dc0745 122Make sure you are in the "win32" subdirectory under the perl toplevel.
137443ea 123This directory contains a "Makefile" that will work with
3e3baf6d 124versions of NMAKE that come with Visual C++ ver. 2.0 and above, and
125a dmake "makefile.mk" that will work for both Borland and Visual C++
126builds. The defaults in the dmake makefile are setup to build using the
127Borland compiler.
68dc0745 128
129=item *
130
3e3baf6d 131Edit the Makefile (or makefile.mk, if using dmake) and change the values
26618a56 132of INST_DRV and INST_TOP. If you are using Visual C++ ver. 2.0, uncomment
133the line that sets "CCTYPE=MSVC20". You can also enable various build
134flags.
135
136If you have either the source or a library that contains des_fcrypt(),
137enable the appropriate option in the makefile. des_fcrypt() is not
138bundled with the distribution due to US Government restrictions
139on the export of cryptographic software. Nevertheless, this routine
140is part of the "libdes" library (written by Ed Young) which is widely
141available worldwide, usually along with SSLeay (for example:
142"ftp://fractal.mta.ca/pub/crypto/SSLeay/DES/"). Set CRYPT_SRC to the
143name of the file that implements des_fcrypt(). Alternatively, if
144you have built a library that contains des_fcrypt(), you can set
145CRYPT_LIB to point to the library name.
146
147Perl will also build without des_fcrypt(), but the crypt() builtin will
148fail at run time.
c90c0ff4 149
3e3baf6d 150You will also have to make sure CCHOME points to wherever you installed
151your compiler.
c90c0ff4 152
68dc0745 153=item *
154
3e3baf6d 155Type "nmake" (or "dmake" if you are using that make).
68dc0745 156
137443ea 157This should build everything. Specifically, it will create perl.exe,
158perl.dll, and perlglob.exe at the perl toplevel, and various other
7bac28a0 159extension dll's under the lib\auto directory. If the build fails for
137443ea 160any reason, make sure you have done the previous steps correctly.
68dc0745 161
156a3eb7 162The build process may produce "harmless" compiler warnings (more or
163less copiously, depending on how picky your compiler gets). The
164maintainers are aware of these warnings, thankyouverymuch. :)
165
3e3baf6d 166When building using Visual C++, a perl95.exe will also get built. This
167executable is only needed on Windows95, and should be used instead of
168perl.exe, and then only if you want sockets to work properly on Windows95.
169This is necessitated by a bug in the Microsoft C Runtime that cannot be
26618a56 170worked around in the "normal" perl.exe. perl95.exe gets built with its
171own private copy of the C Runtime that is not accessible to extensions
172(which see the DLL version of the CRT). Be aware, therefore, that this
173perl95.exe will have esoteric problems with extensions like perl/Tk that
174themselves use the C Runtime heavily, or want to free() pointers
175malloc()-ed by perl.
3e3baf6d 176
177You can avoid the perl95.exe problems completely if you use Borland
178C++ for building perl (perl95.exe is not needed and will not be built
179in that case).
180
68dc0745 181=back
182
183=head2 Testing
184
3e3baf6d 185Type "nmake test" (or "dmake test"). This will run most of the tests from
186the testsuite (many tests will be skipped, and but no test should fail).
68dc0745 187
8b88ae92 188If some tests do fail, it may be because you are using a different command
137443ea 189shell than the native "cmd.exe".
68dc0745 190
3e3baf6d 191If you used the Borland compiler, you may see a failure in op/taint.t
192arising from the inability to find the Borland Runtime DLLs on the system
193default path. You will need to copy the DLLs reported by the messages
194from where Borland chose to install it, into the Windows system directory
195(usually somewhere like C:\WINNT\SYSTEM32), and rerun the test.
196
197Please report any other failures as described under L<BUGS AND CAVEATS>.
68dc0745 198
137443ea 199=head2 Installation
200
3e3baf6d 201Type "nmake install" (or "dmake install"). This will put the newly
26618a56 202built perl and the libraries under whatever C<INST_TOP> points to in the
203Makefile. It will also install the pod documentation under
204C<$INST_TOP\lib\pod> and HTML versions of the same under
205C<$INST_TOP\lib\pod\html>. To use the Perl you just installed,
206set your PATH environment variable to C<$INST_TOP\bin>.
137443ea 207
7bac28a0 208=head2 Usage Hints
209
210=over 4
211
212=item Environment Variables
213
214The installation paths that you set during the build get compiled
215into perl, so you don't have to do anything additional to start
216using that perl (except add its location to your PATH variable).
217
218If you put extensions in unusual places, you can set PERL5LIB
219to a list of paths separated by semicolons where you want perl
220to look for libraries. Look for descriptions of other environment
26618a56 221variables you can set in L<perlrun>.
222
223You can also control the shell that perl uses to run system() and
224backtick commands via PERL5SHELL. See L<perlrun>.
7bac28a0 225
226Sometime in the future, some of the configuration information
227for perl will be moved into the Windows registry.
228
3e3baf6d 229=item File Globbing
230
231By default, perl spawns an external program to do file globbing.
232The install process installs both a perlglob.exe and a perlglob.bat
233that perl can use for this purpose. Note that with the default
234installation, perlglob.exe will be found by the system before
235perlglob.bat.
236
237perlglob.exe relies on the argv expansion done by the C Runtime of
238the particular compiler you used, and therefore behaves very
239differently depending on the Runtime used to build it. To preserve
240compatiblity, perlglob.bat (a perl script/module that can be
241used portably) is installed. Besides being portable, perlglob.bat
242also offers enhanced globbing functionality.
243
244If you want perl to use perlglob.bat instead of perlglob.exe, just
245delete perlglob.exe from the install location (or move it somewhere
246perl cannot find). Using File::DosGlob.pm (which is the same
247as perlglob.bat) to override the internal CORE::glob() works about 10
248times faster than spawing perlglob.exe, and you should take this
249approach when writing new modules. See File::DosGlob for details.
250
7bac28a0 251=item Using perl from the command line
252
253If you are accustomed to using perl from various command-line
254shells found in UNIX environments, you will be less than pleased
255with what Windows NT offers by way of a command shell.
256
257The crucial thing to understand about the "cmd" shell (which is
258the default on Windows NT) is that it does not do any wildcard
259expansions of command-line arguments (so wildcards need not be
260quoted). It also provides only rudimentary quoting. The only
261(useful) quote character is the double quote ("). It can be used to
262protect spaces in arguments and other special characters. The
263Windows NT documentation has almost no description of how the
264quoting rules are implemented, but here are some general observations
265based on experiments: The shell breaks arguments at spaces and
266passes them to programs in argc/argv. Doublequotes can be used
267to prevent arguments with spaces in them from being split up.
268You can put a double quote in an argument by escaping it with
269a backslash and enclosing the whole argument within double quotes.
270The backslash and the pair of double quotes surrounding the
271argument will be stripped by the shell.
272
273The file redirection characters "<", ">", and "|" cannot be quoted
274by double quotes (there are probably more such). Single quotes
275will protect those three file redirection characters, but the
276single quotes don't get stripped by the shell (just to make this
277type of quoting completely useless). The caret "^" has also
278been observed to behave as a quoting character (and doesn't get
279stripped by the shell also).
280
281Here are some examples of usage of the "cmd" shell:
282
283This prints two doublequotes:
284
285 perl -e "print '\"\"' "
286
287This does the same:
288
289 perl -e "print \"\\\"\\\"\" "
290
291This prints "bar" and writes "foo" to the file "blurch":
292
293 perl -e "print 'foo'; print STDERR 'bar'" > blurch
294
295This prints "foo" ("bar" disappears into nowhereland):
296
297 perl -e "print 'foo'; print STDERR 'bar'" 2> nul
298
299This prints "bar" and writes "foo" into the file "blurch":
300
301 perl -e "print 'foo'; print STDERR 'bar'" 1> blurch
302
7bac28a0 303This pipes "foo" to the "less" pager and prints "bar" on the console:
304
305 perl -e "print 'foo'; print STDERR 'bar'" | less
306
307This pipes "foo\nbar\n" to the less pager:
308
7bac28a0 309 perl -le "print 'foo'; print STDERR 'bar'" 2>&1 | less
310
311This pipes "foo" to the pager and writes "bar" in the file "blurch":
312
313 perl -e "print 'foo'; print STDERR 'bar'" 2> blurch | less
314
315
84902520 316Discovering the usefulness of the "command.com" shell on Windows95
7bac28a0 317is left as an exercise to the reader :)
318
319=item Building Extensions
320
321The Comprehensive Perl Archive Network (CPAN) offers a wealth
322of extensions, some of which require a C compiler to build.
323Look in http://www.perl.com/ for more information on CPAN.
324
325Most extensions (whether they require a C compiler or not) can
326be built, tested and installed with the standard mantra:
327
328 perl Makefile.PL
3e3baf6d 329 $MAKE
330 $MAKE test
331 $MAKE install
7bac28a0 332
3e3baf6d 333where $MAKE stands for NMAKE or DMAKE. Some extensions may not
334provide a testsuite (so "$MAKE test" may not do anything, or fail),
335but most serious ones do.
7bac28a0 336
3e3baf6d 337If a module implements XSUBs, you will need one of the supported
338C compilers. You must make sure you have set up the environment for
339the compiler for command-line compilation.
7bac28a0 340
3e3baf6d 341If a module does not build for some reason, look carefully for
7bac28a0 342why it failed, and report problems to the module author. If
343it looks like the extension building support is at fault, report
344that with full details of how the build failed using the perlbug
345utility.
346
c90c0ff4 347=item Win32 Specific Extensions
348
349A number of extensions specific to the Win32 platform are available
350from CPAN. You may find that many of these extensions are meant to
351be used under the Activeware port of Perl, which used to be the only
352native port for the Win32 platform. Since the Activeware port does not
353have adequate support for Perl's extension building tools, these
354extensions typically do not support those tools either, and therefore
355cannot be built using the generic steps shown in the previous section.
356
357To ensure smooth transitioning of existing code that uses the
358Activeware port, there is a bundle of Win32 extensions that contains
359all of the Activeware extensions and most other Win32 extensions from
360CPAN in source form, along with many added bugfixes, and with MakeMaker
361support. This bundle is available at:
362
26618a56 363 http://www.perl.com/CPAN/authors/id/GSAR/libwin32-0.09.tar.gz
c90c0ff4 364
365See the README in that distribution for building and installation
366instructions. Look for later versions that may be available at the
367same location.
368
369It is expected that authors of Win32 specific extensions will begin
370distributing their work in MakeMaker compatible form subsequent to
371the 5.004 release of perl, at which point the need for a dedicated
372bundle such as the above should diminish.
373
156a3eb7 374=item Running Perl Scripts
375
376Perl scripts on UNIX use the "#!" (a.k.a "shebang") line to
377indicate to the OS that it should execute the file using perl.
378Win32 has no comparable means to indicate arbitrary files are
379executables.
380
381Instead, all available methods to execute plain text files on
382Win32 rely on the file "extension". There are three methods
383to use this to execute perl scripts:
384
385=over 8
386
387=item 1
388
389There is a facility called "file extension associations" that will
390work in Windows NT 4.0. This can be manipulated via the two
391commands "assoc" and "ftype" that come standard with Windows NT
3924.0. Type "ftype /?" for a complete example of how to set this
393up for perl scripts (Say what? You thought Windows NT wasn't
394perl-ready? :).
395
396=item 2
397
398Since file associations don't work everywhere, and there are
399reportedly bugs with file associations where it does work, the
400old method of wrapping the perl script to make it look like a
401regular batch file to the OS, may be used. The install process
402makes available the "pl2bat.bat" script which can be used to wrap
403perl scripts into batch files. For example:
404
405 pl2bat foo.pl
406
407will create the file "FOO.BAT". Note "pl2bat" strips any
408.pl suffix and adds a .bat suffix to the generated file.
409
410If you use the 4DOS/NT or similar command shell, note that
411"pl2bat" uses the "%*" variable in the generated batch file to
412refer to all the command line arguments, so you may need to make
413sure that construct works in batch files. As of this writing,
4144DOS/NT users will need a "ParameterChar = *" statement in their
4154NT.INI file, or will need to execute "setdos /p*" in the 4DOS/NT
416startup file to enable this to work.
417
418=item 3
419
420Using "pl2bat" has a few problems: the file name gets changed,
421so scripts that rely on C<$0> to find what they must do may not
422run properly; running "pl2bat" replicates the contents of the
423original script, and so this process can be maintenance intensive
424if the originals get updated often. A different approach that
425avoids both problems is possible.
426
427A script called "runperl.bat" is available that can be copied
428to any filename (along with the .bat suffix). For example,
429if you call it "foo.bat", it will run the file "foo" when it is
430executed. Since you can run batch files on Win32 platforms simply
431by typing the name (without the extension), this effectively
432runs the file "foo", when you type either "foo" or "foo.bat".
433With this method, "foo.bat" can even be in a different location
434than the file "foo", as long as "foo" is available somewhere on
435the PATH. If your scripts are on a filesystem that allows symbolic
436links, you can even avoid copying "runperl.bat".
437
438Here's a diversion: copy "runperl.bat" to "runperl", and type
439"runperl". Explain the observed behavior, or lack thereof. :)
440Hint: .gnidnats llits er'uoy fi ,"lrepnur" eteled :tniH
441
442=back
443
7bac28a0 444=item Miscellaneous Things
445
446A full set of HTML documentation is installed, so you should be
447able to use it if you have a web browser installed on your
448system.
449
450C<perldoc> is also a useful tool for browsing information contained
451in the documentation, especially in conjunction with a pager
452like C<less> (recent versions of which have Win32 support). You may
453have to set the PAGER environment variable to use a specific pager.
454"perldoc -f foo" will print information about the perl operator
455"foo".
456
457If you find bugs in perl, you can run C<perlbug> to create a
458bug report (you may have to send it manually if C<perlbug> cannot
459find a mailer on your system).
460
461=back
462
68dc0745 463=head1 BUGS AND CAVEATS
464
3e3baf6d 465This port should be considered beta quality software at the present
466time because some details are still in flux and there may be
467changes in any of these areas: build process, installation structure,
468supported utilities/modules, and supported perl functionality.
469In particular, functionality specific to the Win32 environment may
f7c603cb 470ultimately be supported as either core modules or extensions. The
471beta status implies, among other things, that you should be prepared
472to recompile extensions when binary incompatibilites arise due to
473changes in the internal structure of the code.
474
475An effort has been made to ensure that the DLLs produced by the two
476supported compilers are compatible with each other (despite the
477best efforts of the compiler vendors). Extension binaries produced
478by one compiler should also coexist with a perl binary built by
479a different compiler. In order to accomplish this, PERL.DLL provides
480a layer of runtime code that uses the C Runtime that perl was compiled
481with. Extensions which include "perl.h" will transparently access
482the functions in this layer, thereby ensuring that both perl and
483extensions use the same runtime functions.
68dc0745 484
8b88ae92 485If you have had prior exposure to Perl on Unix platforms, you will notice
486this port exhibits behavior different from what is documented. Most of the
7bac28a0 487differences fall under one of these categories. We do not consider
488any of them to be serious limitations (especially when compared to the
489limited nature of some of the Win32 OSes themselves :)
68dc0745 490
491=over 8
492
493=item *
494
495C<stat()> and C<lstat()> functions may not behave as documented. They
496may return values that bear no resemblance to those reported on Unix
7bac28a0 497platforms, and some fields (like the the one for inode) may be completely
498bogus.
68dc0745 499
500=item *
501
6890e559 502The following functions are currently unavailable: C<fork()>,
5aabfad6 503C<dump()>, C<chown()>, C<link()>, C<symlink()>, C<chroot()>,
26618a56 504C<setpgrp()> and related security functions, C<setpriority()>,
505C<getpriority()>, C<syscall()>, C<fcntl()>, C<getpw*()>,
2d7a9237 506C<msg*()>, C<shm*()>, C<sem*()>, C<alarm()>, C<socketpair()>,
507C<*netent()>, C<*protoent()>, C<*servent()>, C<*hostent()>,
508C<getnetby*()>.
26618a56 509This list is possibly incomplete.
6890e559 510
511=item *
512
68dc0745 513Various C<socket()> related calls are supported, but they may not
514behave as on Unix platforms.
515
516=item *
517
518The four-argument C<select()> call is only supported on sockets.
519
520=item *
521
f998180f 522The C<ioctl()> call is only supported on sockets (where it provides the
523functionality of ioctlsocket() in the Winsock API).
524
525=item *
526
2d7a9237 527Failure to spawn() a subprocess is indicated by setting $? to "255 << 8".
528C<$?> is set in a way compatible with Unix (i.e. the exitstatus of the
529subprocess is obtained by "$? >> 8", as described in the documentation).
68dc0745 530
531=item *
532
26618a56 533You can expect problems building modules available on CPAN if you
534build perl itself with -DUSE_THREADS. These problems should be resolved
535as we get closer to 5.005.
68dc0745 536
537=item *
538
539C<utime()>, C<times()> and process-related functions may not
540behave as described in the documentation, and some of the
541returned values or effects may be bogus.
542
543=item *
544
3e3baf6d 545Signal handling may not behave as on Unix platforms (where it
f7c603cb 546doesn't exactly "behave", either :). For instance, calling C<die()>
547or C<exit()> from signal handlers will cause an exception, since most
548implementations of C<signal()> on Win32 are severely crippled.
549Thus, signals may work only for simple things like setting a flag
550variable in the handler. Using signals under this port should
551currently be considered unsupported.
68dc0745 552
553=item *
554
7bac28a0 555File globbing may not behave as on Unix platforms. In particular,
3e3baf6d 556if you don't use perlglob.bat for globbing, it will understand
557wildcards only in the filename component (and not in the pathname).
558In other words, something like "print <*/*.pl>" will not print all the
559perl scripts in all the subdirectories one level under the current one
560(like it does on UNIX platforms). perlglob.exe is also dependent on
561the particular implementation of wildcard expansion in the vendor
562libraries used to build it (which varies wildly at the present time).
563Using perlglob.bat (or File::DosGlob) avoids these limitations, but
564still only provides DOS semantics (read "warts") for globbing.
68dc0745 565
566=back
567
568Please send detailed descriptions of any problems and solutions that
569you may find to <F<perlbug@perl.com>>, along with the output produced
570by C<perl -V>.
571
572=head1 AUTHORS
573
574=over 4
575
3e3baf6d 576Gary Ng E<lt>71564.1743@CompuServe.COME<gt>
68dc0745 577
3e3baf6d 578Gurusamy Sarathy E<lt>gsar@umich.eduE<gt>
68dc0745 579
3e3baf6d 580Nick Ing-Simmons E<lt>nick@ni-s.u-net.comE<gt>
68dc0745 581
582=back
583
f7c603cb 584This document is maintained by Gurusamy Sarathy.
585
68dc0745 586=head1 SEE ALSO
587
588L<perl>
589
590=head1 HISTORY
591
592This port was originally contributed by Gary Ng around 5.003_24,
593and borrowed from the Hip Communications port that was available
594at the time.
595
596Nick Ing-Simmons and Gurusamy Sarathy have made numerous and
597sundry hacks since then.
598
3e3baf6d 599Borland support was added in 5.004_01 (Gurusamy Sarathy).
600
2d7a9237 601Last updated: 3 January 1998
68dc0745 602
603=cut
3e3baf6d 604