]> granicus.if.org Git - postgresql/blob - doc/src/sgml/install-windows.sgml
Trim trailing whitespace
[postgresql] / doc / src / sgml / install-windows.sgml
1 <!-- doc/src/sgml/install-windows.sgml -->
2
3 <chapter id="install-windows">
4  <title>Installation from Source Code on <productname>Windows</productname></title>
5
6  <indexterm>
7   <primary>installation</primary>
8   <secondary>on Windows</secondary>
9  </indexterm>
10
11  <para>
12   It is recommended that most users download the binary distribution for
13   Windows, available as a graphical installer package
14   from the <productname>PostgreSQL</productname> website. Building from source
15   is only intended for people developing <productname>PostgreSQL</productname>
16   or extensions.
17  </para>
18
19  <para>
20   There are several different ways of building PostgreSQL on
21   <productname>Windows</productname>. The simplest way to build with
22   Microsoft tools is to install <productname>Visual Studio Express 2015
23   for Windows Desktop</productname> and use the included
24   compiler. It is also possible to build with the full
25   <productname>Microsoft Visual C++ 2005 to 2015</productname>.
26   In some cases that requires the installation of the
27   <productname>Windows SDK</productname> in addition to the compiler.
28  </para>
29
30  <para>
31   It is also possible to build PostgreSQL using the GNU compiler tools
32   provided by <productname>MinGW</productname>, or using
33   <productname>Cygwin</productname> for older versions of
34   <productname>Windows</productname>.
35  </para>
36
37  <para>
38   Building using <productname>MinGW</productname> or
39   <productname>Cygwin</productname> uses the normal build system, see
40   <xref linkend="installation"> and the specific notes in
41   <xref linkend="installation-notes-mingw"> and <xref linkend="installation-notes-cygwin">.
42   To produce native 64 bit binaries in these environments, use the tools from
43   <productname>MinGW-w64</productname>. These tools can also be used to
44   cross-compile for 32 bit and 64 bit <productname>Windows</productname>
45   targets on other hosts, such as <productname>Linux</productname> and
46   <productname>macOS</productname>.
47   <productname>Cygwin</productname> is not recommended for running a
48   production server, and it should only be used for running on
49   older versions of <productname>Windows</productname> where
50   the native build does not work, such as
51   <productname>Windows 98</productname>. The official
52   binaries are built using <productname>Visual Studio</productname>.
53  </para>
54
55  <para>
56   Native builds of <application>psql</application> don't support command
57   line editing. The <productname>Cygwin</productname> build does support
58   command line editing, so it should be used where psql is needed for
59   interactive use on  <productname>Windows</productname>.
60  </para>
61
62  <sect1 id="install-windows-full">
63   <title>Building with <productname>Visual C++</productname> or the
64   <productname>Microsoft Windows SDK</productname></title>
65
66  <para>
67   PostgreSQL can be built using the Visual C++ compiler suite from Microsoft.
68   These compilers can be either from <productname>Visual Studio</productname>,
69   <productname>Visual Studio Express</productname> or some versions of the
70   <productname>Microsoft Windows SDK</productname>. If you do not already have a
71   <productname>Visual Studio</productname> environment set up, the easiest
72   ways are to use the compilers from <productname>Visual Studio Express 2015
73   for Windows Desktop</productname> or those in the <productname>Windows SDK
74   7.1</productname>, which are both free downloads from Microsoft.
75  </para>
76
77  <para>
78   Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite.
79   32-bit PostgreSQL builds are possible with
80   <productname>Visual Studio 2005</productname> to
81   <productname>Visual Studio 2015</productname> (including Express editions),
82   as well as standalone Windows SDK releases 6.0 to 7.1.
83   64-bit PostgreSQL builds are supported with
84   <productname>Microsoft Windows SDK</productname> version 6.0a to 7.1 or
85   <productname>Visual Studio 2008</productname> and above. Compilation
86   is supported down to <productname>Windows XP</productname> and
87   <productname>Windows Server 2003</> when building with
88   <productname>Visual Studio 2005</> to
89   <productname>Visual Studio 2013</productname>. Building with
90   <productname>Visual Studio 2015</productname> is supported down to
91   <productname>Windows Vista</> and <productname>Windows Server 2008</>.
92  </para>
93
94  <para>
95   The tools for building using <productname>Visual C++</productname> or
96   <productname>Platform SDK</productname> are in the
97   <filename>src/tools/msvc</filename> directory. When building, make sure
98   there are no tools from <productname>MinGW</productname> or
99   <productname>Cygwin</productname> present in your system PATH. Also, make
100   sure you have all the required Visual C++ tools available in the PATH. In
101   <productname>Visual Studio</productname>, start the
102   <application>Visual Studio Command Prompt</application>.
103   If you wish to build a 64-bit version, you must use the 64-bit version of
104   the command, and vice versa.
105   In the <productname>Microsoft Windows SDK</productname>, start the
106   <application>CMD shell</application> listed under the SDK on the Start Menu.
107   In recent SDK versions you can change the targeted CPU architecture, build
108   type, and target OS by using the <command>setenv</command> command, e.g.
109   <command>setenv /x86 /release /xp</command> to target Windows XP or later
110   with a 32-bit release build. See <command>/?</command> for other options to
111   <command>setenv</command>.  All commands should be run from the
112   <filename>src\tools\msvc</filename> directory.
113  </para>
114
115  <para>
116   Before you build, you may need to edit the file <filename>config.pl</filename>
117   to reflect any configuration options you want to change, or the paths to
118   any third party libraries to use. The complete configuration is determined
119   by first reading and parsing the file <filename>config_default.pl</filename>,
120   and then apply any changes from <filename>config.pl</filename>. For example,
121   to specify the location of your <productname>Python</productname> installation,
122   put the following in <filename>config.pl</filename>:
123 <programlisting>
124 $config->{python} = 'c:\python26';
125 </programlisting>
126   You only need to specify those parameters that are different from what's in
127   <filename>config_default.pl</filename>.
128  </para>
129
130  <para>
131   If you need to set any other environment variables, create a file called
132   <filename>buildenv.pl</filename> and put the required commands there. For
133   example, to add the path for bison when it's not in the PATH, create a file
134   containing:
135 <programlisting>
136 $ENV{PATH}=$ENV{PATH} . ';c:\some\where\bison\bin';
137 </programlisting>
138  </para>
139
140  <para>
141   To pass additional command line arguments to the Visual Studio build
142   command (msbuild or vcbuild):
143 <programlisting>
144 $ENV{MSBFLAGS}="/m";
145 </programlisting>
146  </para>
147
148  <sect2>
149   <title>Requirements</title>
150   <para>
151    The following additional products are required to build
152    <productname>PostgreSQL</productname>. Use the
153    <filename>config.pl</filename> file to specify which directories the libraries
154    are available in.
155
156    <variablelist>
157     <varlistentry>
158      <term><productname>Microsoft Windows SDK</productname></term>
159      <listitem><para>
160       If your build environment doesn't ship with a supported version of the
161       <productname>Microsoft Windows SDK</productname> it
162       is recommended that you upgrade to the latest version (currently
163       version 7.1), available for download from
164       <ulink url="https://www.microsoft.com/download"></>.
165      </para>
166      <para>
167       You must always include the
168       <application>Windows Headers and Libraries</application> part of the SDK.
169       If you install a <productname>Windows SDK</productname>
170       including the <application>Visual C++ Compilers</application>,
171       you don't need <productname>Visual Studio</productname> to build.
172       Note that as of Version 8.0a the Windows SDK no longer ships with a
173       complete command-line build environment.
174      </para></listitem>
175     </varlistentry>
176
177     <varlistentry>
178      <term><productname>ActiveState Perl</productname></term>
179      <listitem><para>
180       ActiveState Perl is required to run the build generation scripts. MinGW
181       or Cygwin Perl will not work. It must also be present in the PATH.
182       Binaries can be downloaded from
183       <ulink url="http://www.activestate.com"></> (Note: version 5.8 or later is required,
184       the free Standard Distribution is sufficient).
185      </para></listitem>
186     </varlistentry>
187
188    </variablelist>
189   </para>
190   <para>
191    The following additional products are not required to get started,
192    but are required to build the complete package. Use the
193    <filename>config.pl</filename> file to specify which directories the libraries
194    are available in.
195
196    <variablelist>
197     <varlistentry>
198      <term><productname>ActiveState TCL</productname></term>
199      <listitem><para>
200       Required for building <application>PL/Tcl</application> (Note: version
201       8.4 is required, the free Standard Distribution is sufficient).
202      </para></listitem>
203     </varlistentry>
204
205     <varlistentry>
206      <term><productname>Bison</productname> and
207       <productname>Flex</productname></term>
208      <listitem>
209      <para>
210       <productname>Bison</productname> and <productname>Flex</productname> are
211       required to build from Git, but not required when building from a release
212       file. Only <productname>Bison</productname> 1.875 or versions 2.2 and later
213       will work. <productname>Flex</productname> must be version 2.5.31 or later.
214      </para>
215
216      <para>
217       Both <productname>Bison</productname> and <productname>Flex</productname>
218       are included in the <productname>msys</productname> tool suite, available
219       from <ulink url="http://www.mingw.org/wiki/MSYS"></> as part of the
220       <productname>MinGW</productname> compiler suite.
221      </para>
222
223      <para>
224       You will need to add the directory containing
225       <filename>flex.exe</filename> and <filename>bison.exe</filename> to the
226       PATH environment variable in <filename>buildenv.pl</filename> unless
227       they are already in PATH. In the case of MinGW, the directory is the
228       <filename>\msys\1.0\bin</filename> subdirectory of your MinGW
229       installation directory.
230      </para>
231
232      <note>
233       <para>
234         The Bison distribution from GnuWin32 appears to have a bug that
235         causes Bison to malfunction when installed in a directory with
236         spaces in the name, such as the default location on English
237         installations <filename>C:\Program Files\GnuWin32</filename>.
238         Consider installing into <filename>C:\GnuWin32</filename> or use the
239         NTFS short name path to GnuWin32 in your PATH environment setting
240         (e.g. <filename>C:\PROGRA~1\GnuWin32</filename>).
241        </para>
242      </note>
243
244      <note>
245        <para>
246        The obsolete <literal>winflex</literal> binaries distributed on the PostgreSQL FTP site
247        and referenced in older documentation will fail with <quote>flex: fatal
248        internal error, exec failed</quote> on 64-bit Windows hosts. Use Flex from
249        MSYS instead.
250        </para>
251      </note>
252      </listitem>
253     </varlistentry>
254
255     <varlistentry>
256      <term><productname>Diff</productname></term>
257      <listitem><para>
258       Diff is required to run the regression tests, and can be downloaded
259       from <ulink url="http://gnuwin32.sourceforge.net"></>.
260      </para></listitem>
261     </varlistentry>
262
263     <varlistentry>
264      <term><productname>Gettext</productname></term>
265      <listitem><para>
266       Gettext is required to build with NLS support, and can be downloaded
267       from <ulink url="http://gnuwin32.sourceforge.net"></>. Note that binaries,
268       dependencies and developer files are all needed.
269      </para></listitem>
270     </varlistentry>
271
272     <varlistentry>
273      <term><productname>MIT Kerberos</productname></term>
274      <listitem><para>
275       Required for GSSAPI authentication support. MIT Kerberos can be
276       downloaded from
277       <ulink url="http://web.mit.edu/Kerberos/dist/index.html"></>.
278      </para></listitem>
279     </varlistentry>
280
281     <varlistentry>
282      <term><productname>libxml2</productname> and
283       <productname>libxslt</productname></term>
284      <listitem><para>
285       Required for XML support. Binaries can be downloaded from
286       <ulink url="http://zlatkovic.com/pub/libxml"></> or source from
287       <ulink url="http://xmlsoft.org"></>. Note that libxml2 requires iconv,
288       which is available from the same download location.
289      </para></listitem>
290     </varlistentry>
291
292     <varlistentry>
293      <term><productname>openssl</productname></term>
294      <listitem><para>
295       Required for SSL support. Binaries can be downloaded from
296       <ulink url="http://www.slproweb.com/products/Win32OpenSSL.html"></>
297       or source from <ulink url="http://www.openssl.org"></>.
298      </para></listitem>
299     </varlistentry>
300
301     <varlistentry>
302      <term><productname>ossp-uuid</productname></term>
303      <listitem><para>
304       Required for UUID-OSSP support (contrib only). Source can be
305       downloaded from
306       <ulink url="http://www.ossp.org/pkg/lib/uuid/"></>.
307      </para></listitem>
308     </varlistentry>
309
310     <varlistentry>
311      <term><productname>Python</productname></term>
312      <listitem><para>
313       Required for building <application>PL/Python</application>. Binaries can
314       be downloaded from <ulink url="http://www.python.org"></>.
315      </para></listitem>
316     </varlistentry>
317
318     <varlistentry>
319      <term><productname>zlib</productname></term>
320      <listitem><para>
321       Required for compression support in <application>pg_dump</application>
322       and <application>pg_restore</application>. Binaries can be downloaded
323       from <ulink url="http://www.zlib.net"></>.
324      </para></listitem>
325     </varlistentry>
326
327    </variablelist>
328   </para>
329  </sect2>
330
331  <sect2>
332   <title>Special Considerations for 64-bit Windows</title>
333
334   <para>
335    PostgreSQL will only build for the x64 architecture on 64-bit Windows, there
336    is no support for Itanium processors.
337   </para>
338
339   <para>
340    Mixing 32- and 64-bit versions in the same build tree is not supported.
341    The build system will automatically detect if it's running in a 32- or
342    64-bit environment, and build PostgreSQL accordingly. For this reason, it
343    is important to start the correct command prompt before building.
344   </para>
345
346   <para>
347    To use a server-side third party library such as <productname>python</> or
348    <productname>openssl</>, this library <emphasis>must</emphasis> also be
349    64-bit. There is no support for loading a 32-bit library in a 64-bit
350    server. Several of the third party libraries that PostgreSQL supports may
351    only be available in 32-bit versions, in which case they cannot be used with
352    64-bit PostgreSQL.
353   </para>
354  </sect2>
355
356  <sect2>
357   <title>Building</title>
358
359   <para>
360    To build all of PostgreSQL in release configuration (the default), run the
361    command:
362 <screen>
363 <userinput>build</userinput>
364 </screen>
365    To build all of PostgreSQL in debug configuration, run the command:
366 <screen>
367 <userinput>build DEBUG</userinput>
368 </screen>
369    To build just a single project, for example psql, run the commands:
370 <screen>
371 <userinput>build psql</userinput>
372 <userinput>build DEBUG psql</userinput>
373 </screen>
374    To change the default build configuration to debug, put the following
375    in the <filename>buildenv.pl</filename> file:
376 <programlisting>
377 $ENV{CONFIG}="Debug";
378 </programlisting>
379   </para>
380
381   <para>
382    It is also possible to build from inside the Visual Studio GUI. In this
383    case, you need to run:
384 <screen>
385 <userinput>perl mkvcbuild.pl</userinput>
386 </screen>
387    from the command prompt, and then open the generated
388    <filename>pgsql.sln</filename> (in the root directory of the source tree)
389    in Visual Studio.
390   </para>
391  </sect2>
392
393  <sect2>
394   <title>Cleaning and Installing</title>
395
396   <para>
397    Most of the time, the automatic dependency tracking in Visual Studio will
398    handle changed files. But if there have been large changes, you may need
399    to clean the installation. To do this, simply run the
400    <filename>clean.bat</filename> command, which will automatically clean out
401    all generated files. You can also run it with the
402    <parameter>dist</parameter> parameter, in which case it will behave like
403    <userinput>make distclean</userinput> and remove the flex/bison output files
404    as well.
405   </para>
406
407   <para>
408    By default, all files are written into a subdirectory of the
409    <filename>debug</filename> or <filename>release</filename> directories. To
410    install these files using the standard layout, and also generate the files
411    required to initialize and use the database, run the command:
412 <screen>
413 <userinput>install c:\destination\directory</userinput>
414 </screen>
415   </para>
416
417   <para>
418    If you want to install only the client applications and
419    interface libraries, then you can use these commands:
420 <screen>
421 <userinput>install c:\destination\directory client</userinput>
422 </screen>
423   </para>
424  </sect2>
425
426  <sect2>
427   <title>Running the Regression Tests</title>
428
429   <para>
430    To run the regression tests, make sure you have completed the build of all
431    required parts first. Also, make sure that the DLLs required to load all
432    parts of the system (such as the Perl and Python DLLs for the procedural
433    languages) are present in the system path. If they are not, set it through
434    the <filename>buildenv.pl</filename> file. To run the tests, run one of
435    the following commands from the <filename>src\tools\msvc</filename>
436    directory:
437 <screen>
438 <userinput>vcregress check</userinput>
439 <userinput>vcregress installcheck</userinput>
440 <userinput>vcregress plcheck</userinput>
441 <userinput>vcregress contribcheck</userinput>
442 <userinput>vcregress modulescheck</userinput>
443 <userinput>vcregress ecpgcheck</userinput>
444 <userinput>vcregress isolationcheck</userinput>
445 <userinput>vcregress bincheck</userinput>
446 <userinput>vcregress recoverycheck</userinput>
447 <userinput>vcregress upgradecheck</userinput>
448 </screen>
449
450    To change the schedule used (default is parallel), append it to the
451    command line like:
452 <screen>
453 <userinput>vcregress check serial</userinput>
454 </screen>
455
456    For more information about the regression tests, see
457    <xref linkend="regress">.
458   </para>
459
460   <para>
461    Running the regression tests on client programs, with
462    <command>vcregress bincheck</>, or on recovery tests, with
463    <command>vcregress recoverycheck</>, requires an additional Perl module
464    to be installed:
465    <variablelist>
466     <varlistentry>
467      <term><productname>IPC::Run</productname></term>
468      <listitem><para>
469       As of this writing, <literal>IPC::Run</> is not included in the
470       ActiveState Perl installation, nor in the ActiveState Perl Package
471       Manager (PPM) library. To install, download the
472       <filename>IPC-Run-&lt;version&gt;.tar.gz</> source archive from CPAN,
473       at <ulink url="http://search.cpan.org/dist/IPC-Run/"></>, and
474       uncompress. Edit the <filename>buildenv.pl</> file, and add a PERL5LIB
475       variable to point to the <filename>lib</> subdirectory from the
476       extracted archive. For example:
477 <programlisting>
478 $ENV{PERL5LIB}=$ENV{PERL5LIB} . ';c:\IPC-Run-0.94\lib';
479 </programlisting>
480      </para></listitem>
481     </varlistentry>
482    </variablelist>
483   </para>
484  </sect2>
485
486  <sect2>
487   <title>Building the Documentation</title>
488
489   <para>
490    Building the PostgreSQL documentation in HTML format requires several tools
491    and files. Create a root directory for all these files, and store them
492    in the subdirectories in the list below.
493    <variablelist>
494     <varlistentry>
495      <term>OpenJade 1.3.1-2</term>
496      <listitem><para>
497       Download from
498       <ulink url="http://sourceforge.net/projects/openjade/files/openjade/1.3.1/openjade-1_3_1-2-bin.zip/download"></>
499       and uncompress in the subdirectory <filename>openjade-1.3.1</filename>.
500      </para></listitem>
501     </varlistentry>
502
503     <varlistentry>
504      <term>DocBook DTD 4.2</term>
505      <listitem><para>
506       Download from
507       <ulink url="http://www.oasis-open.org/docbook/sgml/4.2/docbook-4.2.zip"></>
508       and uncompress in the subdirectory <filename>docbook</filename>.
509      </para></listitem>
510     </varlistentry>
511
512     <varlistentry>
513      <term>ISO character entities</term>
514      <listitem><para>
515       Download from
516       <ulink url="http://www.oasis-open.org/cover/ISOEnts.zip"></> and
517       uncompress in the subdirectory <filename>docbook</filename>.
518      </para></listitem>
519     </varlistentry>
520    </variablelist>
521    Edit the <filename>buildenv.pl</filename> file, and add a variable for the
522    location of the root directory, for example:
523 <programlisting>
524 $ENV{DOCROOT}='c:\docbook';
525 </programlisting>
526    To build the documentation, run the command
527    <filename>builddoc.bat</filename>. Note that this will actually run the
528    build twice, in order to generate the indexes. The generated HTML files
529    will be in <filename>doc\src\sgml</filename>.
530   </para>
531  </sect2>
532
533  </sect1>
534 </chapter>