perlwin32.html

来自「perl教程」· HTML 代码 · 共 1,020 行 · 第 1/4 页

HTML
1,020
字号
        ar='link /lib'</pre>
<p>It may also be useful to create a batch file called lib.bat in
C:\Program Files\Microsoft Visual C++ Toolkit 2003\bin containing:</p>
<pre>
        @echo off
        link /lib %*</pre>
<p>for the benefit of any naughty C extension modules that you might want to build
later which explicitly reference &quot;lib&quot; rather than taking their value from
$Config{ar}.</p>
</li>
<li>
<p>setargv.obj is required to build perlglob.exe (and perl.exe if the USE_SETARGV
option is enabled).  The Platform SDK supplies this object file in source form
in C:\Program Files\Microsoft SDK\src\crt.  Copy setargv.c, cruntime.h and
internal.h from there to some temporary location and build setargv.obj using</p>
<pre>
        cl.exe /c /I. /D_CRTBLD setargv.c</pre>
<p>Then copy setargv.obj to C:\Program Files\Microsoft SDK\lib</p>
<p>Alternatively, if you don't need perlglob.exe and don't need to enable the
USE_SETARGV option then you can safely just remove all mention of $(GLOBEXE)
from win32/Makefile and setargv.obj won't be required anyway.</p>
</li>
</ul>
<p>Perl should now build using the win32/Makefile.  You will need to edit that
file to set</p>
<pre>
        CCTYPE = MSVC70FREE</pre>
<p>and to set CCHOME, CCINCDIR and CCLIBDIR as per the environment setup above.</p>
<dt><strong><a name="item_microsoft_platform_sdk_64_2dbit_compiler">Microsoft Platform SDK 64-bit Compiler</a></strong>

<dd>
<p>The nmake that comes with the Platform SDK will suffice for building
Perl.  Make sure you are building within one of the &quot;Build Environment&quot;
shells available after you install the Platform SDK from the Start Menu.</p>
</dd>
</li>
<dt><strong><a name="item_mingw_release_3_with_gcc">MinGW release 3 with gcc</a></strong>

<dd>
<p>The latest release of MinGW at the time of writing is 3.1.0, which contains
gcc-3.2.3.  It can be downloaded here:</p>
</dd>
<dd>
<pre>
    <a href="http://www.mingw.org/">http://www.mingw.org/</a></pre>
</dd>
<dd>
<p>Perl also compiles with earlier releases of gcc (2.95.2 and up).  See below
for notes about using earlier versions of MinGW/gcc.</p>
</dd>
<dd>
<p>You also need dmake.  See <a href="#item_make">Make</a> above on how to get it.</p>
</dd>
</li>
<dt><strong><a name="item_mingw_release_1_with_gcc">MinGW release 1 with gcc</a></strong>

<dd>
<p>The MinGW-1.1 bundle contains gcc-2.95.3.</p>
</dd>
<dd>
<p>Make sure you install the binaries that work with MSVCRT.DLL as indicated
in the README for the GCC bundle.  You may need to set up a few environment
variables (usually ran from a batch file).</p>
</dd>
<dd>
<p>There are a couple of problems with the version of gcc-2.95.2-msvcrt.exe
released 7 November 1999:</p>
</dd>
<ul>
<li>
<p>It left out a fix for certain command line quotes.  To fix this, be sure
to download and install the file fixes/quote-fix-msvcrt.exe from the above
ftp location.</p>
</li>
<li>
<p>The definition of the fpos_t type in stdio.h may be wrong.  If your
stdio.h has this problem, you will see an exception when running the
test t/lib/io_xs.t.  To fix this, change the typedef for fpos_t from
&quot;long&quot; to &quot;long long&quot; in the file i386-mingw32msvc/include/stdio.h,
and rebuild.</p>
</li>
</ul>
<p>A potentially simpler to install (but probably soon-to-be-outdated) bundle
of the above package with the mentioned fixes already applied is available
here:</p>
<pre>
    <a href="http://downloads.ActiveState.com/pub/staff/gsar/gcc-2.95.2-msvcrt.zip">http://downloads.ActiveState.com/pub/staff/gsar/gcc-2.95.2-msvcrt.zip</a>
    <a href="ftp://ftp.ActiveState.com/pub/staff/gsar/gcc-2.95.2-msvcrt.zip">ftp://ftp.ActiveState.com/pub/staff/gsar/gcc-2.95.2-msvcrt.zip</a></pre>
</dl>
<p>
</p>
<h2><a name="building">Building</a></h2>
<ul>
<li>
<p>Make sure you are in the &quot;win32&quot; subdirectory under the perl toplevel.
This directory contains a &quot;Makefile&quot; that will work with
versions of nmake that come with Visual C++ or the Platform SDK, and
a dmake &quot;makefile.mk&quot; that will work for all supported compilers.  The
defaults in the dmake makefile are setup to build using MinGW/gcc.</p>
</li>
<li>
<p>Edit the makefile.mk (or Makefile, if you're using nmake) and change
the values of INST_DRV and INST_TOP.   You can also enable various
build flags.  These are explained in the makefiles.</p>
<p>Note that it is generally not a good idea to try to build a perl with
INST_DRV and INST_TOP set to a path that already exists from a previous
build.  In particular, this may cause problems with the
lib/ExtUtils/t/Embed.t test, which attempts to build a test program and
may end up building against the installed perl's lib/CORE directory rather
than the one being tested.</p>
<p>You will have to make sure that CCTYPE is set correctly and that
CCHOME points to wherever you installed your compiler.</p>
<p>The default value for CCHOME in the makefiles for Visual C++
may not be correct for some versions.  Make sure the default exists
and is valid.</p>
<p>You may also need to comment out the <code>DELAYLOAD = ...</code> line in the
Makefile if you're using VC++ 6.0 without the latest service pack and
the linker reports an internal error.</p>
<p>If you have either the source or a library that contains des_fcrypt(),
enable the appropriate option in the makefile.  A ready-to-use version
of fcrypt.c, based on the version originally written by Eric Young at
<a href="ftp://ftp.funet.fi/pub/crypt/mirrors/dsi/libdes/,">ftp://ftp.funet.fi/pub/crypt/mirrors/dsi/libdes/,</a> is bundled with the
distribution and CRYPT_SRC is set to use it.
Alternatively, if you have built a library that contains des_fcrypt(),
you can set CRYPT_LIB to point to the library name.
Perl will also build without des_fcrypt(), but the <a href="../../lib/Pod/perlfunc.html#item_crypt"><code>crypt()</code></a> builtin will
fail at run time.</p>
<p>If you want build some core extensions statically into perl's dll, specify
them in the STATIC_EXT macro.</p>
<p>Be sure to read the instructions near the top of the makefiles carefully.</p>
</li>
<li>
<p>Type &quot;dmake&quot; (or &quot;nmake&quot; if you are using that make).</p>
<p>This should build everything.  Specifically, it will create perl.exe,
perl58.dll at the perl toplevel, and various other extension dll's
under the lib\auto directory.  If the build fails for any reason, make
sure you have done the previous steps correctly.</p>
</li>
</ul>
<p>
</p>
<h2><a name="testing_perl_on_win32">Testing Perl on Win32</a></h2>
<p>Type &quot;dmake test&quot; (or &quot;nmake test&quot;).  This will run most of the tests from
the testsuite (many tests will be skipped).</p>
<p>There should be no test failures when running under Windows NT/2000/XP.
Many tests <em>will</em> fail under Windows 9x due to the inferior command shell.</p>
<p>Some test failures may occur if you use a command shell other than the
native &quot;cmd.exe&quot;, or if you are building from a path that contains
spaces.  So don't do that.</p>
<p>If you are running the tests from a emacs shell window, you may see
failures in op/stat.t.  Run &quot;dmake test-notty&quot; in that case.</p>
<p>If you're using the Borland compiler, you may see a failure in op/taint.t
arising from the inability to find the Borland Runtime DLLs on the system
default path.  You will need to copy the DLLs reported by the messages
from where Borland chose to install it, into the Windows system directory
(usually somewhere like C:\WINNT\SYSTEM32) and rerun the test.</p>
<p>If you're using Borland compiler versions 5.2 and below, you may run into
problems finding the correct header files when building extensions.  For
example, building the &quot;Tk&quot; extension may fail because both perl and Tk
contain a header file called &quot;patchlevel.h&quot;.  The latest Borland compiler
(v5.5) is free of this misbehaviour, and it even supports an
option -VI- for backward (bugward) compatibility for using the old Borland
search algorithm  to locate header files.</p>
<p>If you run the tests on a FAT partition, you may see some failures for
<a href="../../lib/Pod/perlfunc.html#item_link"><code>link()</code></a> related tests:</p>
<pre>
    Failed Test                     Stat Wstat Total Fail  Failed  List</pre>
<pre>
    ../ext/IO/lib/IO/t/io_dup.t                    6    4  66.67%  2-5
    ../lib/File/Temp/t/mktemp.t                    9    1  11.11%  2
    ../lib/File/Temp/t/posix.t                     7    1  14.29%  3
    ../lib/File/Temp/t/security.t                 13    1   7.69%  2
    ../lib/File/Temp/t/tempfile.t                 20    2  10.00%  2 4
    comp/multiline.t                               6    2  33.33%  5-6
    io/dup.t                                       8    6  75.00%  2-7
    op/write.t                                    47    7  14.89%  1-3 6 9-11</pre>
<p>Testing on NTFS avoids these errors.</p>
<p>Furthermore, you should make sure that during <code>make test</code> you do not
have any GNU tool packages in your path: some toolkits like Unixutils
include some tools (<code>type</code> for instance) which override the Windows
ones and makes tests fail. Remove them from your path while testing to
avoid these errors.</p>
<p>Please report any other failures as described under <a href="#bugs_and_caveats">BUGS AND CAVEATS</a>.</p>
<p>
</p>
<h2><a name="installation_of_perl_on_win32">Installation of Perl on Win32</a></h2>
<p>Type &quot;dmake install&quot; (or &quot;nmake install&quot;).  This will put the newly
built perl and the libraries under whatever <code>INST_TOP</code> points to in the
Makefile.  It will also install the pod documentation under
<code>$INST_TOP\$INST_VER\lib\pod</code> and HTML versions of the same under
<code>$INST_TOP\$INST_VER\lib\pod\html</code>.</p>
<p>To use the Perl you just installed you will need to add a new entry to
your PATH environment variable: <code>$INST_TOP\bin</code>, e.g.</p>
<pre>
    <span class="variable">set</span> <span class="variable">PATH</span><span class="operator">=</span><span class="variable">c</span><span class="operator">:\</span><span class="variable">perl</span><span class="operator">\</span><span class="variable">bin</span><span class="operator">;</span><span class="variable">%PATH</span><span class="operator">%
    </span>
</pre>
<p>If you opted to uncomment <code>INST_VER</code> and <code>INST_ARCH</code> in the makefile
then the installation structure is a little more complicated and you will
need to add two new PATH components instead: <code>$INST_TOP\$INST_VER\bin</code> and
<code>$INST_TOP\$INST_VER\bin\$ARCHNAME</code>, e.g.</p>
<pre>
    <span class="variable">set</span> <span class="variable">PATH</span><span class="operator">=</span><span class="variable">c</span><span class="operator">:\</span><span class="variable">perl</span><span class="operator">\</span><span class="number">5.6</span><span class="operator">.</span><span class="number">0</span><span class="operator">\</span><span class="variable">bin</span><span class="operator">;</span><span class="variable">c</span><span class="operator">:\</span><span class="variable">perl</span><span class="operator">\</span><span class="number">5.6</span><span class="operator">.</span><span class="number">0</span><span class="operator">\</span><span class="variable">bin</span><span class="operator">\</span><span class="variable">MSWin32</span><span class="operator">-</span><span class="variable">x86</span><span class="operator">;</span><span class="variable">%PATH</span><span class="operator">%
    </span>
</pre>
<p>
</p>
<h2><a name="usage_hints_for_perl_on_win32">Usage Hints for Perl on Win32</a></h2>
<dl>
<dt><strong><a name="item_environment_variables">Environment Variables</a></strong>

<dd>
<p>The installation paths that you set during the build get compiled
into perl, so you don't have to do anything additional to start
using that perl (except add its location to your PATH variable).</p>
</dd>
<dd>
<p>If you put extensions in unusual places, you can set PERL5LIB
to a list of paths separated by semicolons where you want perl
to look for libraries.  Look for descriptions of other environment
variables you can set in <a href="../../lib/Pod/perlrun.html">the perlrun manpage</a>.</p>
</dd>
<dd>
<p>You can also control the shell that perl uses to run <a href="../../lib/Pod/perlfunc.html#item_system"><code>system()</code></a> and
backtick commands via PERL5SHELL.  See <a href="../../lib/Pod/perlrun.html">the perlrun manpage</a>.</p>
</dd>
<dd>
<p>Perl does not depend on the registry, but it can look up certain default
values if you choose to put them there.  Perl attempts to read entries from
<code>HKEY_CURRENT_USER\Software\Perl</code> and <code>HKEY_LOCAL_MACHINE\Software\Perl</code>.
Entries in the former override entries in the latter.  One or more of the
following entries (of type REG_SZ or REG_EXPAND_SZ) may be set:</p>
</dd>
<dd>
<pre>
    lib-$]              version-specific standard library path to add to @INC
    lib                 standard library path to add to @INC
    sitelib-$]          version-specific site library path to add to @INC
    sitelib             site library path to add to @INC
    vendorlib-$]        version-specific vendor library path to add to @INC
    vendorlib           vendor library path to add to @INC
    PERL*               fallback for all %ENV lookups that begin with &quot;PERL&quot;</pre>
</dd>
<dd>
<p>Note the <a href="../../lib/Pod/perlvar.html#item___"><code>$]</code></a> in the above is not literal.  Substitute whatever version
of perl you want to honor that entry, e.g. <code>5.6.0</code>.  Paths must be
separated with semicolons, as usual on win32.</p>
</dd>
</li>
<dt><strong><a name="item_file_globbing">File Globbing</a></strong>

<dd>
<p>By default, perl handles file globbing using the File::Glob extension,
which provides portable globbing.</p>
</dd>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?