summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/install-windows-full.html
blob: 22621a2c6dc9bbed9b75a6b6679fd9445f370df3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>18.1. Building with Visual C++ or the Microsoft Windows SDK</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="install-windows.html" title="Chapter 18. Installation from Source Code on Windows" /><link rel="next" href="runtime.html" title="Chapter 19. Server Setup and Operation" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">18.1. Building with <span class="productname">Visual C++</span> or the
  <span class="productname">Microsoft Windows SDK</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="install-windows.html" title="Chapter 18. Installation from Source Code on Windows">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="install-windows.html" title="Chapter 18. Installation from Source Code on Windows">Up</a></td><th width="60%" align="center">Chapter 18. Installation from Source Code on <span class="productname">Windows</span></th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 15.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="runtime.html" title="Chapter 19. Server Setup and Operation">Next</a></td></tr></table><hr /></div><div class="sect1" id="INSTALL-WINDOWS-FULL"><div class="titlepage"><div><div><h2 class="title" style="clear: both">18.1. Building with <span class="productname">Visual C++</span> or the
  <span class="productname">Microsoft Windows SDK</span></h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="install-windows-full.html#id-1.6.5.8.8">18.1.1. Requirements</a></span></dt><dt><span class="sect2"><a href="install-windows-full.html#id-1.6.5.8.9">18.1.2. Special Considerations for 64-Bit Windows</a></span></dt><dt><span class="sect2"><a href="install-windows-full.html#id-1.6.5.8.10">18.1.3. Building</a></span></dt><dt><span class="sect2"><a href="install-windows-full.html#id-1.6.5.8.11">18.1.4. Cleaning and Installing</a></span></dt><dt><span class="sect2"><a href="install-windows-full.html#id-1.6.5.8.12">18.1.5. Running the Regression Tests</a></span></dt></dl></div><p>
  PostgreSQL can be built using the Visual C++ compiler suite from Microsoft.
  These compilers can be either from <span class="productname">Visual Studio</span>,
  <span class="productname">Visual Studio Express</span> or some versions of the
  <span class="productname">Microsoft Windows SDK</span>. If you do not already have a
  <span class="productname">Visual Studio</span> environment set up, the easiest
  ways are to use the compilers from
  <span class="productname">Visual Studio 2022</span> or those in the
  <span class="productname">Windows SDK 10</span>, which are both free downloads
  from Microsoft.
 </p><p>
  Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite.
  32-bit PostgreSQL builds are possible with
  <span class="productname">Visual Studio 2013</span> to
  <span class="productname">Visual Studio 2022</span>,
  as well as standalone Windows SDK releases 8.1a to 10.
  64-bit PostgreSQL builds are supported with
  <span class="productname">Microsoft Windows SDK</span> version 8.1a to 10 or
  <span class="productname">Visual Studio 2013</span> and above. Compilation
  is supported down to <span class="productname">Windows 7</span> and
  <span class="productname">Windows Server 2008 R2 SP1</span> when building with
  <span class="productname">Visual Studio 2013</span> to
  <span class="productname">Visual Studio 2022</span>.
   
 </p><p>
  The tools for building using <span class="productname">Visual C++</span> or
  <span class="productname">Platform SDK</span> are in the
  <code class="filename">src\tools\msvc</code> directory. When building, make sure
  there are no tools from <span class="productname">MinGW</span> or
  <span class="productname">Cygwin</span> present in your system PATH. Also, make
  sure you have all the required Visual C++ tools available in the PATH. In
  <span class="productname">Visual Studio</span>, start the
  <span class="application">Visual Studio Command Prompt</span>.
  If you wish to build a 64-bit version, you must use the 64-bit version of
  the command, and vice versa.
  Starting with <span class="productname">Visual Studio 2017</span> this can be
  done from the command line using <code class="command">VsDevCmd.bat</code>, see
  <code class="command">-help</code> for the available options and their default values.
  <code class="command">vsvars32.bat</code> is available in
  <span class="productname">Visual Studio 2015</span> and earlier versions for the
  same purpose.
  From the <span class="application">Visual Studio Command Prompt</span>, you can
  change the targeted CPU architecture, build type, and target OS by using the
  <code class="command">vcvarsall.bat</code> command, e.g.,
  <code class="command">vcvarsall.bat x64 10.0.10240.0</code> to target Windows 10
  with a 64-bit release build. See <code class="command">-help</code> for the other
  options of <code class="command">vcvarsall.bat</code>. All commands should be run from
  the <code class="filename">src\tools\msvc</code> directory.
 </p><p>
  Before you build, you can create the file <code class="filename">config.pl</code>
  to reflect any configuration options you want to change, or the paths to
  any third party libraries to use. The complete configuration is determined
  by first reading and parsing the file <code class="filename">config_default.pl</code>,
  and then apply any changes from <code class="filename">config.pl</code>. For example,
  to specify the location of your <span class="productname">Python</span> installation,
  put the following in <code class="filename">config.pl</code>:
</p><pre class="programlisting">
$config-&gt;{python} = 'c:\python310';
</pre><p>
  You only need to specify those parameters that are different from what's in
  <code class="filename">config_default.pl</code>.
 </p><p>
  If you need to set any other environment variables, create a file called
  <code class="filename">buildenv.pl</code> and put the required commands there. For
  example, to add the path for bison when it's not in the PATH, create a file
  containing:
</p><pre class="programlisting">
$ENV{PATH}=$ENV{PATH} . ';c:\some\where\bison\bin';
</pre><p>
 </p><p>
  To pass additional command line arguments to the Visual Studio build
  command (msbuild or vcbuild):
</p><pre class="programlisting">
$ENV{MSBFLAGS}="/m";
</pre><p>
 </p><div class="sect2" id="id-1.6.5.8.8"><div class="titlepage"><div><div><h3 class="title">18.1.1. Requirements</h3></div></div></div><p>
   The following additional products are required to build
   <span class="productname">PostgreSQL</span>. Use the
   <code class="filename">config.pl</code> file to specify which directories the libraries
   are available in.

   </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="productname">Microsoft Windows SDK</span></span></dt><dd><p>
      If your build environment doesn't ship with a supported version of the
      <span class="productname">Microsoft Windows SDK</span> it
      is recommended that you upgrade to the latest version (currently
      version 10), available for download from
      <a class="ulink" href="https://www.microsoft.com/download" target="_top">https://www.microsoft.com/download</a>.
     </p><p>
      You must always include the
      <span class="application">Windows Headers and Libraries</span> part of the SDK.
      If you install a <span class="productname">Windows SDK</span>
      including the <span class="application">Visual C++ Compilers</span>,
      you don't need <span class="productname">Visual Studio</span> to build.
      Note that as of Version 8.0a the Windows SDK no longer ships with a
      complete command-line build environment.
     </p></dd><dt><span class="term"><span class="productname">ActiveState Perl</span></span></dt><dd><p>
      ActiveState Perl is required to run the build generation scripts. MinGW
      or Cygwin Perl will not work. It must also be present in the PATH.
      Binaries can be downloaded from
      <a class="ulink" href="https://www.activestate.com" target="_top">https://www.activestate.com</a>
      (Note: version 5.8.3 or later is required,
      the free Standard Distribution is sufficient).
     </p></dd></dl></div><p>
  </p><p>
   The following additional products are not required to get started,
   but are required to build the complete package. Use the
   <code class="filename">config.pl</code> file to specify which directories the libraries
   are available in.

   </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="productname">ActiveState TCL</span></span></dt><dd><p>
      Required for building <span class="application">PL/Tcl</span> (Note: version
      8.4 is required, the free Standard Distribution is sufficient).
     </p></dd><dt><span class="term"><span class="productname">Bison</span> and
      <span class="productname">Flex</span></span></dt><dd><p>
      <span class="productname">Bison</span> and <span class="productname">Flex</span> are
      required to build from Git, but not required when building from a release
      file. Only <span class="productname">Bison</span> 1.875 or versions 2.2 and later
      will work. <span class="productname">Flex</span> must be version 2.5.31 or later.
     </p><p>
      Both <span class="productname">Bison</span> and <span class="productname">Flex</span>
      are included in the <span class="productname">msys</span> tool suite, available
      from <a class="ulink" href="http://www.mingw.org/wiki/MSYS" target="_top">http://www.mingw.org/wiki/MSYS</a> as part of the
      <span class="productname">MinGW</span> compiler suite.
     </p><p>
      You will need to add the directory containing
      <code class="filename">flex.exe</code> and <code class="filename">bison.exe</code> to the
      PATH environment variable in <code class="filename">buildenv.pl</code> unless
      they are already in PATH. In the case of MinGW, the directory is the
      <code class="filename">\msys\1.0\bin</code> subdirectory of your MinGW
      installation directory.
     </p><div class="note"><h3 class="title">Note</h3><p>
        The Bison distribution from GnuWin32 appears to have a bug that
        causes Bison to malfunction when installed in a directory with
        spaces in the name, such as the default location on English
        installations <code class="filename">C:\Program Files\GnuWin32</code>.
        Consider installing into <code class="filename">C:\GnuWin32</code> or use the
        NTFS short name path to GnuWin32 in your PATH environment setting
        (e.g., <code class="filename">C:\PROGRA~1\GnuWin32</code>).
       </p></div></dd><dt><span class="term"><span class="productname">Diff</span></span></dt><dd><p>
      Diff is required to run the regression tests, and can be downloaded
      from <a class="ulink" href="http://gnuwin32.sourceforge.net" target="_top">http://gnuwin32.sourceforge.net</a>.
     </p></dd><dt><span class="term"><span class="productname">Gettext</span></span></dt><dd><p>
      Gettext is required to build with NLS support, and can be downloaded
      from <a class="ulink" href="http://gnuwin32.sourceforge.net" target="_top">http://gnuwin32.sourceforge.net</a>. Note that binaries,
      dependencies and developer files are all needed.
     </p></dd><dt><span class="term"><span class="productname">MIT Kerberos</span></span></dt><dd><p>
      Required for GSSAPI authentication support. MIT Kerberos can be
      downloaded from
      <a class="ulink" href="https://web.mit.edu/Kerberos/dist/index.html" target="_top">https://web.mit.edu/Kerberos/dist/index.html</a>.
     </p></dd><dt><span class="term"><span class="productname">libxml2</span> and
      <span class="productname">libxslt</span></span></dt><dd><p>
      Required for XML support. Binaries can be downloaded from
      <a class="ulink" href="https://zlatkovic.com/pub/libxml" target="_top">https://zlatkovic.com/pub/libxml</a> or source from
      <a class="ulink" href="http://xmlsoft.org" target="_top">http://xmlsoft.org</a>. Note that libxml2 requires iconv,
      which is available from the same download location.
     </p></dd><dt><span class="term"><span class="productname">LZ4</span></span></dt><dd><p>
      Required for supporting <span class="productname">LZ4</span> compression.
      Binaries and source can be downloaded from
      <a class="ulink" href="https://github.com/lz4/lz4/releases" target="_top">https://github.com/lz4/lz4/releases</a>.
     </p></dd><dt><span class="term"><span class="productname">Zstandard</span></span></dt><dd><p>
      Required for supporting <span class="productname">Zstandard</span> compression.
      Binaries and source can be downloaded from
      <a class="ulink" href="https://github.com/facebook/zstd/releases" target="_top">https://github.com/facebook/zstd/releases</a>.
     </p></dd><dt><span class="term"><span class="productname">OpenSSL</span></span></dt><dd><p>
      Required for SSL support. Binaries can be downloaded from
      <a class="ulink" href="https://slproweb.com/products/Win32OpenSSL.html" target="_top">https://slproweb.com/products/Win32OpenSSL.html</a>
      or source from <a class="ulink" href="https://www.openssl.org" target="_top">https://www.openssl.org</a>.
     </p></dd><dt><span class="term"><span class="productname">ossp-uuid</span></span></dt><dd><p>
      Required for UUID-OSSP support (contrib only). Source can be
      downloaded from
      <a class="ulink" href="http://www.ossp.org/pkg/lib/uuid/" target="_top">http://www.ossp.org/pkg/lib/uuid/</a>.
     </p></dd><dt><span class="term"><span class="productname">Python</span></span></dt><dd><p>
      Required for building <span class="application">PL/Python</span>. Binaries can
      be downloaded from <a class="ulink" href="https://www.python.org" target="_top">https://www.python.org</a>.
     </p></dd><dt><span class="term"><span class="productname">zlib</span></span></dt><dd><p>
      Required for compression support in <span class="application">pg_dump</span>
      and <span class="application">pg_restore</span>. Binaries can be downloaded
      from <a class="ulink" href="https://www.zlib.net" target="_top">https://www.zlib.net</a>.
     </p></dd></dl></div><p>
  </p></div><div class="sect2" id="id-1.6.5.8.9"><div class="titlepage"><div><div><h3 class="title">18.1.2. Special Considerations for 64-Bit Windows</h3></div></div></div><p>
   PostgreSQL will only build for the x64 architecture on 64-bit Windows, there
   is no support for Itanium processors.
  </p><p>
   Mixing 32- and 64-bit versions in the same build tree is not supported.
   The build system will automatically detect if it's running in a 32- or
   64-bit environment, and build PostgreSQL accordingly. For this reason, it
   is important to start the correct command prompt before building.
  </p><p>
   To use a server-side third party library such as <span class="productname">Python</span> or
   <span class="productname">OpenSSL</span>, this library <span class="emphasis"><em>must</em></span> also be
   64-bit. There is no support for loading a 32-bit library in a 64-bit
   server. Several of the third party libraries that PostgreSQL supports may
   only be available in 32-bit versions, in which case they cannot be used with
   64-bit PostgreSQL.
  </p></div><div class="sect2" id="id-1.6.5.8.10"><div class="titlepage"><div><div><h3 class="title">18.1.3. Building</h3></div></div></div><p>
   To build all of PostgreSQL in release configuration (the default), run the
   command:
</p><pre class="screen">
<strong class="userinput"><code>build</code></strong>
</pre><p>
   To build all of PostgreSQL in debug configuration, run the command:
</p><pre class="screen">
<strong class="userinput"><code>build DEBUG</code></strong>
</pre><p>
   To build just a single project, for example psql, run the commands:
</p><pre class="screen">
<strong class="userinput"><code>build psql</code></strong>
<strong class="userinput"><code>build DEBUG psql</code></strong>
</pre><p>
   To change the default build configuration to debug, put the following
   in the <code class="filename">buildenv.pl</code> file:
</p><pre class="programlisting">
$ENV{CONFIG}="Debug";
</pre><p>
  </p><p>
   It is also possible to build from inside the Visual Studio GUI. In this
   case, you need to run:
</p><pre class="screen">
<strong class="userinput"><code>perl mkvcbuild.pl</code></strong>
</pre><p>
   from the command prompt, and then open the generated
   <code class="filename">pgsql.sln</code> (in the root directory of the source tree)
   in Visual Studio.
  </p></div><div class="sect2" id="id-1.6.5.8.11"><div class="titlepage"><div><div><h3 class="title">18.1.4. Cleaning and Installing</h3></div></div></div><p>
   Most of the time, the automatic dependency tracking in Visual Studio will
   handle changed files. But if there have been large changes, you may need
   to clean the installation. To do this, simply run the
   <code class="filename">clean.bat</code> command, which will automatically clean out
   all generated files. You can also run it with the
   <em class="parameter"><code>dist</code></em> parameter, in which case it will behave like
   <strong class="userinput"><code>make distclean</code></strong> and remove the flex/bison output files
   as well.
  </p><p>
   By default, all files are written into a subdirectory of the
   <code class="filename">debug</code> or <code class="filename">release</code> directories. To
   install these files using the standard layout, and also generate the files
   required to initialize and use the database, run the command:
</p><pre class="screen">
<strong class="userinput"><code>install c:\destination\directory</code></strong>
</pre><p>
  </p><p>
   If you want to install only the client applications and
   interface libraries, then you can use these commands:
</p><pre class="screen">
<strong class="userinput"><code>install c:\destination\directory client</code></strong>
</pre><p>
  </p></div><div class="sect2" id="id-1.6.5.8.12"><div class="titlepage"><div><div><h3 class="title">18.1.5. Running the Regression Tests</h3></div></div></div><p>
   To run the regression tests, make sure you have completed the build of all
   required parts first. Also, make sure that the DLLs required to load all
   parts of the system (such as the Perl and Python DLLs for the procedural
   languages) are present in the system path. If they are not, set it through
   the <code class="filename">buildenv.pl</code> file. To run the tests, run one of
   the following commands from the <code class="filename">src\tools\msvc</code>
   directory:
</p><pre class="screen">
<strong class="userinput"><code>vcregress check</code></strong>
<strong class="userinput"><code>vcregress installcheck</code></strong>
<strong class="userinput"><code>vcregress plcheck</code></strong>
<strong class="userinput"><code>vcregress contribcheck</code></strong>
<strong class="userinput"><code>vcregress modulescheck</code></strong>
<strong class="userinput"><code>vcregress ecpgcheck</code></strong>
<strong class="userinput"><code>vcregress isolationcheck</code></strong>
<strong class="userinput"><code>vcregress bincheck</code></strong>
<strong class="userinput"><code>vcregress recoverycheck</code></strong>
</pre><p>

   To change the schedule used (default is parallel), append it to the
   command line like:
</p><pre class="screen">
<strong class="userinput"><code>vcregress check serial</code></strong>
</pre><p>

   For more information about the regression tests, see
   <a class="xref" href="regress.html" title="Chapter 33. Regression Tests">Chapter 33</a>.
  </p><p>
   Running the regression tests on client programs, with
   <code class="command">vcregress bincheck</code>, or on recovery tests, with
   <code class="command">vcregress recoverycheck</code>, requires an additional Perl module
   to be installed:
   </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="productname">IPC::Run</span></span></dt><dd><p>
      As of this writing, <code class="literal">IPC::Run</code> is not included in the
      ActiveState Perl installation, nor in the ActiveState Perl Package
      Manager (PPM) library. To install, download the
      <code class="filename">IPC-Run-&lt;version&gt;.tar.gz</code> source archive from CPAN,
      at <a class="ulink" href="https://metacpan.org/release/IPC-Run" target="_top">https://metacpan.org/release/IPC-Run</a>, and
      uncompress. Edit the <code class="filename">buildenv.pl</code> file, and add a PERL5LIB
      variable to point to the <code class="filename">lib</code> subdirectory from the
      extracted archive. For example:
</p><pre class="programlisting">
$ENV{PERL5LIB}=$ENV{PERL5LIB} . ';c:\IPC-Run-0.94\lib';
</pre><p>
     </p></dd></dl></div><p>
  </p><p>
   The TAP tests run with <code class="command">vcregress</code> support the
   environment variables <code class="varname">PROVE_TESTS</code>, that is expanded
   automatically using the name patterns given, and
   <code class="varname">PROVE_FLAGS</code>. These can be set on a Windows terminal,
   before running <code class="command">vcregress</code>:
</p><pre class="programlisting">
set PROVE_FLAGS=--timer --jobs 2
set PROVE_TESTS=t/020*.pl t/010*.pl
</pre><p>
   It is also possible to set up those parameters in
   <code class="filename">buildenv.pl</code>:
</p><pre class="programlisting">
$ENV{PROVE_FLAGS}='--timer --jobs 2'
$ENV{PROVE_TESTS}='t/020*.pl t/010*.pl'
</pre><p>
  </p><p>
   Some of the TAP tests depend on a set of external commands that would
   optionally trigger tests related to them. Each one of those variables
   can be set or unset in <code class="filename">buildenv.pl</code>:
   </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="varname">GZIP_PROGRAM</code></span></dt><dd><p>
      Path to a <span class="application">gzip</span> command. The default is
      <code class="literal">gzip</code>, which will search for a command by that
      name in the configured <code class="envar">PATH</code>.
     </p></dd><dt><span class="term"><code class="varname">LZ4</code></span></dt><dd><p>
      Path to a <span class="application">lz4</span> command. The default is
      <code class="literal">lz4</code>, which will search for a command by that
      name in the configured <code class="envar">PATH</code>.
     </p></dd><dt><span class="term"><code class="varname">TAR</code></span></dt><dd><p>
      Path to a <span class="application">tar</span> command. The default is
      <code class="literal">tar</code>, which will search for a command by that
      name in the configured <code class="envar">PATH</code>.
     </p></dd><dt><span class="term"><code class="varname">ZSTD</code></span></dt><dd><p>
      Path to a <span class="application">zstd</span> command. The default is
      <code class="literal">zstd</code>, which will search for a command by that
      name in the configured <code class="envar">PATH</code>.
     </p></dd></dl></div><p>
  </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="install-windows.html" title="Chapter 18. Installation from Source Code on Windows">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="install-windows.html" title="Chapter 18. Installation from Source Code on Windows">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="runtime.html" title="Chapter 19. Server Setup and Operation">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 18. Installation from Source Code on <span class="productname">Windows</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.4 Documentation">Home</a></td><td width="40%" align="right" valign="top"> Chapter 19. Server Setup and Operation</td></tr></table></div></body></html>