perlcygwin.html

来自「perl教程」· HTML 代码 · 共 675 行 · 第 1/3 页

HTML
675
字号
<ul>
<li><strong><a name="item__2duusedl"><code>-Uusedl</code></a></strong>

<p>Undefining this symbol forces Perl to be compiled statically.</p>
</li>
<li><strong><a name="item__2duusemymalloc"><code>-Uusemymalloc</code></a></strong>

<p>By default Perl uses the <code>malloc()</code> included with the Perl source.  If you
want to force Perl to build with the system <code>malloc()</code> undefine this symbol.</p>
</li>
<li><strong><a name="item__2duuseperlio"><code>-Uuseperlio</code></a></strong>

<p>Undefining this symbol disables the PerlIO abstraction.  PerlIO is now the
default; it is not recommended to disable PerlIO.</p>
</li>
<li><strong><a name="item__2ddusemultiplicity"><code>-Dusemultiplicity</code></a></strong>

<p>Multiplicity is required when embedding Perl in a C program and using
more than one interpreter instance.  This works with the Cygwin port.</p>
</li>
<li><strong><a name="item__2dduse64bitint"><code>-Duse64bitint</code></a></strong>

<p>By default Perl uses 32 bit integers.  If you want to use larger 64
bit integers, define this symbol.</p>
</li>
<li><strong><a name="item__2dduselongdouble"><code>-Duselongdouble</code></a></strong>

<p><em>gcc</em> supports long doubles (12 bytes).  However, several additional
long double math functions are necessary to use them within Perl
(<em>{atan2, cos, exp, floor, fmod, frexp, isnan, log, modf, pow, sin, sqrt}l, 
strtold</em>).
These are <strong>not</strong> yet available with Cygwin.</p>
</li>
<li><strong><a name="item__2ddusethreads"><code>-Dusethreads</code></a></strong>

<p>POSIX threads are implemented in Cygwin, define this symbol if you want
a threaded perl.</p>
</li>
<li><strong><a name="item__2dduselargefiles"><code>-Duselargefiles</code></a></strong>

<p>Cygwin uses 64-bit integers for internal size and position calculations, 
this will be correctly detected and defined by Configure.</p>
</li>
<li><strong><a name="item__2ddmksymlinks"><code>-Dmksymlinks</code></a></strong>

<p>Use this to build perl outside of the source tree.  This works with Cygwin.
Details can be found in the <em>INSTALL</em> document.  This is the recommended 
way to build perl from sources.</p>
</li>
</ul>
<p>
</p>
<h2><a name="suspicious_warnings_on_cygwin">Suspicious Warnings on Cygwin</a></h2>
<p>You may see some messages during Configure that seem suspicious.</p>
<ul>
<li><strong><a name="item_dlsym"><em>dlsym()</em></a></strong>

<p><em>ld2</em> is needed to build dynamic libraries, but it does not exist
when <a href="#item_dlsym"><code>dlsym()</code></a> checking occurs (it is not created until <code>make</code> runs).
You will see the following message:</p>
<pre>
  Checking whether your C&lt;dlsym()&gt; needs a leading underscore ...
  ld2: not found
  I can't compile and run the test program.
  I'm guessing that dlsym doesn't need a leading underscore.</pre>
<p>Since the guess is correct, this is not a problem.</p>
</li>
<li><strong><a name="item_win9x_and_d_eofnblk">Win9x and <code>d_eofnblk</code></a></strong>

<p>Win9x does not correctly report <code>EOF</code> with a non-blocking read on a
closed pipe.  You will see the following messages:</p>
<pre>
  But it also returns -1 to signal EOF, so be careful!
  WARNING: you can't distinguish between EOF and no data!</pre>
<pre>
  *** WHOA THERE!!! ***
      The recommended value for $d_eofnblk on this machine was &quot;define&quot;!
      Keep the recommended value? [y]</pre>
<p>At least for consistency with WinNT, you should keep the recommended
value.</p>
</li>
<li><strong><a name="item_compiler_2fpreprocessor_defines">Compiler/Preprocessor defines</a></strong>

<p>The following error occurs because of the Cygwin <code>#define</code> of
<code>_LONG_DOUBLE</code>:</p>
<pre>
  Guessing which symbols your C compiler and preprocessor define...
  try.c:&lt;line#&gt;: missing binary operator</pre>
<p>This failure does not seem to cause any problems.  With older gcc
versions, &quot;parse error&quot; is reported instead of &quot;missing binary
operator&quot;.</p>
</li>
</ul>
<p>
</p>
<hr />
<h1><a name="make_on_cygwin">MAKE ON CYGWIN</a></h1>
<p>Simply run <em>make</em> and wait:</p>
<pre>
  make 2&gt;&amp;1 | tee log.make</pre>
<p>
</p>
<h2><a name="errors_on_cygwin">Errors on Cygwin</a></h2>
<p>Errors like these are normal:</p>
<pre>
  ...
  make: [extra.pods] Error 1 (ignored)
  ...
  make: [extras.make] Error 1 (ignored)</pre>
<p>
</p>
<h2><a name="ld2_on_cygwin">ld2 on Cygwin</a></h2>
<p>During <code>make</code>, <em>ld2</em> will be created and installed in your $installbin
directory (where you said to put public executables).  It does not
wait until the <code>make install</code> process to install the <em>ld2</em> script,
this is because the remainder of the <code>make</code> refers to <em>ld2</em> without
fully specifying its path and does this from multiple subdirectories.
The assumption is that $installbin is in your current <a href="#item_path"><code>PATH</code></a>.  If this
is not the case <code>make</code> will fail at some point.  If this happens,
just manually copy <em>ld2</em> from the source directory to somewhere in
your <a href="#item_path"><code>PATH</code></a>.</p>
<p>
</p>
<hr />
<h1><a name="test_on_cygwin">TEST ON CYGWIN</a></h1>
<p>There are two steps to running the test suite:</p>
<pre>
  make test 2&gt;&amp;1 | tee log.make-test</pre>
<pre>
  <span class="variable">cd</span> <span class="variable">t</span><span class="operator">;.</span><span class="regex">/perl harness 2&gt;&amp;1 | tee ../log</span><span class="operator">.</span><span class="variable">harness</span>
</pre>
<p>The same tests are run both times, but more information is provided when
running as <code>./perl harness</code>.</p>
<p>Test results vary depending on your host system and your Cygwin
configuration.  If a test can pass in some Cygwin setup, it is always
attempted and explainable test failures are documented.  It is possible
for Perl to pass all the tests, but it is more likely that some tests
will fail for one of the reasons listed below.</p>
<p>
</p>
<h2><a name="file_permissions_on_cygwin">File Permissions on Cygwin</a></h2>
<p>UNIX file permissions are based on sets of mode bits for
{read,write,execute} for each {user,group,other}.  By default Cygwin
only tracks the Win32 read-only attribute represented as the UNIX file
user write bit (files are always readable, files are executable if they
have a <em>.{com,bat,exe}</em> extension or begin with <code>#!</code>, directories are
always readable and executable).  On WinNT with the <em>ntea</em> <code>CYGWIN</code>
setting, the additional mode bits are stored as extended file attributes.
On WinNT with the <em>ntsec</em> <code>CYGWIN</code> setting, permissions use the standard
WinNT security descriptors and access control lists.  Without one of
these options, these tests will fail (listing not updated yet):</p>
<pre>
  Failed Test           List of failed
  ------------------------------------
  io/fs.t               5, 7, 9-10
  lib/anydbm.t          2
  lib/db-btree.t        20
  lib/db-hash.t         16
  lib/db-recno.t        18
  lib/gdbm.t            2
  lib/ndbm.t            2
  lib/odbm.t            2
  lib/sdbm.t            2
  op/stat.t             9, 20 (.tmp not an executable extension)</pre>
<p>
</p>
<h2><a name="ndbm_file_and_odbm_file_do_not_work_on_fat_filesystems">NDBM_File and ODBM_File do not work on FAT filesystems</a></h2>
<p>Do not use NDBM_File or ODBM_File on FAT filesystem.  They can be
built on a FAT filesystem, but many tests will fail:</p>
<pre>
 ../ext/NDBM_File/ndbm.t       13  3328    71   59  83.10%  1-2 4 16-71
 ../ext/ODBM_File/odbm.t      255 65280    ??   ??       %  ??
 ../lib/AnyDBM_File.t           2   512    12    2  16.67%  1 4
 ../lib/Memoize/t/errors.t      0   139    11    5  45.45%  7-11
 ../lib/Memoize/t/tie_ndbm.t   13  3328     4    4 100.00%  1-4
 run/fresh_perl.t                          97    1   1.03%  91</pre>
<p>If you intend to run only on FAT (or if using AnyDBM_File on FAT),
run Configure with the -Ui_ndbm and -Ui_dbm options to prevent
NDBM_File and ODBM_File being built.</p>
<p>With NTFS (and CYGWIN=ntsec), there should be no problems even if
perl was built on FAT.</p>
<p>
</p>
<h2><a name="fork___failures_in_io___tests"><a href="../../lib/Pod/perlfunc.html#item_fork"><code>fork()</code></a> failures in io_* tests</a></h2>
<p>A <a href="../../lib/Pod/perlfunc.html#item_fork"><code>fork()</code></a> failure may result in the following tests failing:</p>
<pre>
  ext/IO/lib/IO/t/io_multihomed.t
  ext/IO/lib/IO/t/io_sock.t
  ext/IO/lib/IO/t/io_unix.t</pre>
<p>See comment on fork in <a href="#item_miscellaneous">Miscellaneous</a> below.</p>
<p>
</p>
<hr />
<h1><a name="specific_features_of_the_cygwin_port">Specific features of the Cygwin port</a></h1>
<p>
</p>
<h2><a name="script_portability_on_cygwin">Script Portability on Cygwin</a></h2>
<p>Cygwin does an outstanding job of providing UNIX-like semantics on top of
Win32 systems.  However, in addition to the items noted above, there are
some differences that you should know about.  This is a very brief guide
to portability, more information can be found in the Cygwin documentation.</p>
<ul>
<li><strong><a name="item_pathnames">Pathnames</a></strong>

<p>Cygwin pathnames can be separated by forward (<em>/</em>) or backward (<em>\\</em>)
slashes.  They may also begin with drive letters (<em>C:</em>) or Universal
Naming Codes (<em>//UNC</em>).  DOS device names (<em>aux</em>, <em>con</em>, <em>prn</em>,
<em>com*</em>, <em>lpt?</em>, <em>nul</em>) are invalid as base filenames.  However, they
can be used in extensions (e.g., <em>hello.aux</em>).  Names may contain all
printable characters except these:</p>
<pre>
  : * ? &quot; &lt; &gt; |</pre>
<p>File names are case insensitive, but case preserving.  A pathname that
contains a backslash or drive letter is a Win32 pathname (and not subject
to the translations applied to POSIX style pathnames).</p>
</li>
<li><strong><a name="item_text_2fbinary">Text/Binary</a></strong>

<p>When a file is opened it is in either text or binary mode.  In text mode
a file is subject to CR/LF/Ctrl-Z translations.  With Cygwin, the default
mode for an <a href="../../lib/Pod/perlfunc.html#item_open"><code>open()</code></a> is determined by the mode of the mount that underlies
the file.  Perl provides a <a href="../../lib/Pod/perlfunc.html#item_binmode"><code>binmode()</code></a> function to set binary mode on files
that otherwise would be treated as text.  <a href="../../lib/Pod/perlfunc.html#item_sysopen"><code>sysopen()</code></a> with the <code>O_TEXT</code>
flag sets text mode on files that otherwise would be treated as binary:</p>
<pre>

⌨️ 快捷键说明

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