Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
install-windows-full.html344 linesDownload Raw Back to html
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>2<!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 the3  <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 16.3 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 the4  <span class="productname">Microsoft Windows SDK</span> <a href="#INSTALL-WINDOWS-FULL" class="id_link">#</a></h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="install-windows-full.html#INSTALL-WINDOWS-FULL-REQUIREMENTS">18.1.1. Requirements</a></span></dt><dt><span class="sect2"><a href="install-windows-full.html#INSTALL-WINDOWS-FULL-64-BIT">18.1.2. Special Considerations for 64-Bit Windows</a></span></dt><dt><span class="sect2"><a href="install-windows-full.html#INSTALL-WINDOWS-FULL-BUILD">18.1.3. Building</a></span></dt><dt><span class="sect2"><a href="install-windows-full.html#INSTALL-WINDOWS-FULL-CLEAN-INST">18.1.4. Cleaning and Installing</a></span></dt><dt><span class="sect2"><a href="install-windows-full.html#INSTALL-WINDOWS-FULL-REG-TESTS">18.1.5. Running the Regression Tests</a></span></dt></dl></div><p>5  PostgreSQL can be built using the Visual C++ compiler suite from Microsoft.6  These compilers can be either from <span class="productname">Visual Studio</span>,7  <span class="productname">Visual Studio Express</span> or some versions of the8  <span class="productname">Microsoft Windows SDK</span>. If you do not already have a9  <span class="productname">Visual Studio</span> environment set up, the easiest10  ways are to use the compilers from11  <span class="productname">Visual Studio 2022</span> or those in the12  <span class="productname">Windows SDK 10</span>, which are both free downloads13  from Microsoft.14 </p><p>15  Both 32-bit and 64-bit builds are possible with the Microsoft Compiler suite.16  32-bit PostgreSQL builds are possible with17  <span class="productname">Visual Studio 2015</span> to18  <span class="productname">Visual Studio 2022</span>,19  as well as standalone Windows SDK releases 10 and above.20  64-bit PostgreSQL builds are supported with21  <span class="productname">Microsoft Windows SDK</span> version 10 and above or22  <span class="productname">Visual Studio 2015</span> and above.23   24 </p><p>25  The tools for building using <span class="productname">Visual C++</span> or26  <span class="productname">Platform SDK</span> are in the27  <code class="filename">src\tools\msvc</code> directory. When building, make sure28  there are no tools from <span class="productname">MinGW</span> or29  <span class="productname">Cygwin</span> present in your system PATH. Also, make30  sure you have all the required Visual C++ tools available in the PATH. In31  <span class="productname">Visual Studio</span>, start the32  <span class="application">Visual Studio Command Prompt</span>.33  If you wish to build a 64-bit version, you must use the 64-bit version of34  the command, and vice versa.35  Starting with <span class="productname">Visual Studio 2017</span> this can be36  done from the command line using <code class="command">VsDevCmd.bat</code>, see37  <code class="command">-help</code> for the available options and their default values.38  <code class="command">vsvars32.bat</code> is available in39  <span class="productname">Visual Studio 2015</span> and earlier versions for the40  same purpose.41  From the <span class="application">Visual Studio Command Prompt</span>, you can42  change the targeted CPU architecture, build type, and target OS by using the43  <code class="command">vcvarsall.bat</code> command, e.g.,44  <code class="command">vcvarsall.bat x64 10.0.10240.0</code> to target Windows 1045  with a 64-bit release build. See <code class="command">-help</code> for the other46  options of <code class="command">vcvarsall.bat</code>. All commands should be run from47  the <code class="filename">src\tools\msvc</code> directory.48 </p><p>49  Before you build, you can create the file <code class="filename">config.pl</code>50  to reflect any configuration options you want to change, or the paths to51  any third party libraries to use. The complete configuration is determined52  by first reading and parsing the file <code class="filename">config_default.pl</code>,53  and then apply any changes from <code class="filename">config.pl</code>. For example,54  to specify the location of your <span class="productname">Python</span> installation,55  put the following in <code class="filename">config.pl</code>:56</p><pre class="programlisting">57$config-&gt;{python} = 'c:\python310';58</pre><p>59  You only need to specify those parameters that are different from what's in60  <code class="filename">config_default.pl</code>.61 </p><p>62  If you need to set any other environment variables, create a file called63  <code class="filename">buildenv.pl</code> and put the required commands there. For64  example, to add the path for bison when it's not in the PATH, create a file65  containing:66</p><pre class="programlisting">67$ENV{PATH}=$ENV{PATH} . ';c:\some\where\bison\bin';68</pre><p>69 </p><p>70  To pass additional command line arguments to the Visual Studio build71  command (msbuild or vcbuild):72</p><pre class="programlisting">73$ENV{MSBFLAGS}="/m";74</pre><p>75 </p><div class="sect2" id="INSTALL-WINDOWS-FULL-REQUIREMENTS"><div class="titlepage"><div><div><h3 class="title">18.1.1. Requirements <a href="#INSTALL-WINDOWS-FULL-REQUIREMENTS" class="id_link">#</a></h3></div></div></div><p>76   The following additional products are required to build77   <span class="productname">PostgreSQL</span>. Use the78   <code class="filename">config.pl</code> file to specify which directories the libraries79   are available in.80 81   </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="productname">Microsoft Windows SDK</span></span></dt><dd><p>82      If your build environment doesn't ship with a supported version of the83      <span class="productname">Microsoft Windows SDK</span> it84      is recommended that you upgrade to the latest version (currently85      version 10), available for download from86      <a class="ulink" href="https://www.microsoft.com/download" target="_top">https://www.microsoft.com/download</a>.87     </p><p>88      You must always include the89      <span class="application">Windows Headers and Libraries</span> part of the SDK.90      If you install a <span class="productname">Windows SDK</span>91      including the <span class="application">Visual C++ Compilers</span>,92      you don't need <span class="productname">Visual Studio</span> to build.93      Note that as of Version 8.0a the Windows SDK no longer ships with a94      complete command-line build environment.95     </p></dd><dt><span class="term"><span class="productname">ActiveState Perl</span></span></dt><dd><p>96      ActiveState Perl is required to run the build generation scripts. MinGW97      or Cygwin Perl will not work. It must also be present in the PATH.98      Binaries can be downloaded from99      <a class="ulink" href="https://www.activestate.com" target="_top">https://www.activestate.com</a>100      (Note: version 5.14 or later is required,101      the free Standard Distribution is sufficient).102     </p></dd></dl></div><p>103  </p><p>104   The following additional products are not required to get started,105   but are required to build the complete package. Use the106   <code class="filename">config.pl</code> file to specify which directories the libraries107   are available in.108 109   </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="productname">ActiveState TCL</span></span></dt><dd><p>110      Required for building <span class="application">PL/Tcl</span> (Note: version111      8.4 is required, the free Standard Distribution is sufficient).112     </p></dd><dt><span class="term"><span class="productname">Bison</span> and113      <span class="productname">Flex</span></span></dt><dd><p>114      <span class="productname">Bison</span> and <span class="productname">Flex</span> are115      required to build from Git, but not required when building from a release116      file. Only <span class="productname">Bison</span> versions 2.3 and later117      will work. <span class="productname">Flex</span> must be version 2.5.35 or later.118     </p><p>119      Both <span class="productname">Bison</span> and <span class="productname">Flex</span>120      are included in the <span class="productname">msys</span> tool suite, available121      from <a class="ulink" href="http://www.mingw.org/wiki/MSYS" target="_top">http://www.mingw.org/wiki/MSYS</a> as part of the122      <span class="productname">MinGW</span> compiler suite.123     </p><p>124      You will need to add the directory containing125      <code class="filename">flex.exe</code> and <code class="filename">bison.exe</code> to the126      PATH environment variable in <code class="filename">buildenv.pl</code> unless127      they are already in PATH. In the case of MinGW, the directory is the128      <code class="filename">\msys\1.0\bin</code> subdirectory of your MinGW129      installation directory.130     </p><div class="note"><h3 class="title">Note</h3><p>131        The Bison distribution from GnuWin32 appears to have a bug that132        causes Bison to malfunction when installed in a directory with133        spaces in the name, such as the default location on English134        installations <code class="filename">C:\Program Files\GnuWin32</code>.135        Consider installing into <code class="filename">C:\GnuWin32</code> or use the136        NTFS short name path to GnuWin32 in your PATH environment setting137        (e.g., <code class="filename">C:\PROGRA~1\GnuWin32</code>).138       </p></div></dd><dt><span class="term"><span class="productname">Diff</span></span></dt><dd><p>139      Diff is required to run the regression tests, and can be downloaded140      from <a class="ulink" href="http://gnuwin32.sourceforge.net" target="_top">http://gnuwin32.sourceforge.net</a>.141     </p></dd><dt><span class="term"><span class="productname">Gettext</span></span></dt><dd><p>142      Gettext is required to build with NLS support, and can be downloaded143      from <a class="ulink" href="http://gnuwin32.sourceforge.net" target="_top">http://gnuwin32.sourceforge.net</a>. Note that binaries,144      dependencies and developer files are all needed.145     </p></dd><dt><span class="term"><span class="productname">MIT Kerberos</span></span></dt><dd><p>146      Required for GSSAPI authentication support. MIT Kerberos can be147      downloaded from148      <a class="ulink" href="https://web.mit.edu/Kerberos/dist/index.html" target="_top">https://web.mit.edu/Kerberos/dist/index.html</a>.149     </p></dd><dt><span class="term"><span class="productname">libxml2</span> and150      <span class="productname">libxslt</span></span></dt><dd><p>151      Required for XML support. Binaries can be downloaded from152      <a class="ulink" href="https://zlatkovic.com/pub/libxml" target="_top">https://zlatkovic.com/pub/libxml</a> or source from153      <a class="ulink" href="http://xmlsoft.org" target="_top">http://xmlsoft.org</a>. Note that libxml2 requires iconv,154      which is available from the same download location.155     </p></dd><dt><span class="term"><span class="productname">LZ4</span></span></dt><dd><p>156      Required for supporting <span class="productname">LZ4</span> compression.157      Binaries and source can be downloaded from158      <a class="ulink" href="https://github.com/lz4/lz4/releases" target="_top">https://github.com/lz4/lz4/releases</a>.159     </p></dd><dt><span class="term"><span class="productname">Zstandard</span></span></dt><dd><p>160      Required for supporting <span class="productname">Zstandard</span> compression.161      Binaries and source can be downloaded from162      <a class="ulink" href="https://github.com/facebook/zstd/releases" target="_top">https://github.com/facebook/zstd/releases</a>.163     </p></dd><dt><span class="term"><span class="productname">OpenSSL</span></span></dt><dd><p>164      Required for SSL support. Binaries can be downloaded from165      <a class="ulink" href="https://slproweb.com/products/Win32OpenSSL.html" target="_top">https://slproweb.com/products/Win32OpenSSL.html</a>166      or source from <a class="ulink" href="https://www.openssl.org" target="_top">https://www.openssl.org</a>.167     </p></dd><dt><span class="term"><span class="productname">ossp-uuid</span></span></dt><dd><p>168      Required for UUID-OSSP support (contrib only). Source can be169      downloaded from170      <a class="ulink" href="http://www.ossp.org/pkg/lib/uuid/" target="_top">http://www.ossp.org/pkg/lib/uuid/</a>.171     </p></dd><dt><span class="term"><span class="productname">Python</span></span></dt><dd><p>172      Required for building <span class="application">PL/Python</span>. Binaries can173      be downloaded from <a class="ulink" href="https://www.python.org" target="_top">https://www.python.org</a>.174     </p></dd><dt><span class="term"><span class="productname">zlib</span></span></dt><dd><p>175      Required for compression support in <span class="application">pg_dump</span>176      and <span class="application">pg_restore</span>. Binaries can be downloaded177      from <a class="ulink" href="https://www.zlib.net" target="_top">https://www.zlib.net</a>.178     </p></dd></dl></div><p>179  </p></div><div class="sect2" id="INSTALL-WINDOWS-FULL-64-BIT"><div class="titlepage"><div><div><h3 class="title">18.1.2. Special Considerations for 64-Bit Windows <a href="#INSTALL-WINDOWS-FULL-64-BIT" class="id_link">#</a></h3></div></div></div><p>180   PostgreSQL will only build for the x64 architecture on 64-bit Windows.181  </p><p>182   Mixing 32- and 64-bit versions in the same build tree is not supported.183   The build system will automatically detect if it's running in a 32- or184   64-bit environment, and build PostgreSQL accordingly. For this reason, it185   is important to start the correct command prompt before building.186  </p><p>187   To use a server-side third party library such as <span class="productname">Python</span> or188   <span class="productname">OpenSSL</span>, this library <span class="emphasis"><em>must</em></span> also be189   64-bit. There is no support for loading a 32-bit library in a 64-bit190   server. Several of the third party libraries that PostgreSQL supports may191   only be available in 32-bit versions, in which case they cannot be used with192   64-bit PostgreSQL.193  </p></div><div class="sect2" id="INSTALL-WINDOWS-FULL-BUILD"><div class="titlepage"><div><div><h3 class="title">18.1.3. Building <a href="#INSTALL-WINDOWS-FULL-BUILD" class="id_link">#</a></h3></div></div></div><p>194   To build all of PostgreSQL in release configuration (the default), run the195   command:196</p><pre class="screen">197<strong class="userinput"><code>build</code></strong>198</pre><p>199   To build all of PostgreSQL in debug configuration, run the command:200</p><pre class="screen">201<strong class="userinput"><code>build DEBUG</code></strong>202</pre><p>203   To build just a single project, for example psql, run the commands:204</p><pre class="screen">205<strong class="userinput"><code>build psql</code></strong>206<strong class="userinput"><code>build DEBUG psql</code></strong>207</pre><p>208   To change the default build configuration to debug, put the following209   in the <code class="filename">buildenv.pl</code> file:210</p><pre class="programlisting">211$ENV{CONFIG}="Debug";212</pre><p>213  </p><p>214   It is also possible to build from inside the Visual Studio GUI. In this215   case, you need to run:216</p><pre class="screen">217<strong class="userinput"><code>perl mkvcbuild.pl</code></strong>218</pre><p>219   from the command prompt, and then open the generated220   <code class="filename">pgsql.sln</code> (in the root directory of the source tree)221   in Visual Studio.222  </p></div><div class="sect2" id="INSTALL-WINDOWS-FULL-CLEAN-INST"><div class="titlepage"><div><div><h3 class="title">18.1.4. Cleaning and Installing <a href="#INSTALL-WINDOWS-FULL-CLEAN-INST" class="id_link">#</a></h3></div></div></div><p>223   Most of the time, the automatic dependency tracking in Visual Studio will224   handle changed files. But if there have been large changes, you may need225   to clean the installation. To do this, simply run the226   <code class="filename">clean.bat</code> command, which will automatically clean out227   all generated files. You can also run it with the228   <em class="parameter"><code>dist</code></em> parameter, in which case it will behave like229   <strong class="userinput"><code>make distclean</code></strong> and remove the flex/bison output files230   as well.231  </p><p>232   By default, all files are written into a subdirectory of the233   <code class="filename">debug</code> or <code class="filename">release</code> directories. To234   install these files using the standard layout, and also generate the files235   required to initialize and use the database, run the command:236</p><pre class="screen">237<strong class="userinput"><code>install c:\destination\directory</code></strong>238</pre><p>239  </p><p>240   If you want to install only the client applications and241   interface libraries, then you can use these commands:242</p><pre class="screen">243<strong class="userinput"><code>install c:\destination\directory client</code></strong>244</pre><p>245  </p></div><div class="sect2" id="INSTALL-WINDOWS-FULL-REG-TESTS"><div class="titlepage"><div><div><h3 class="title">18.1.5. Running the Regression Tests <a href="#INSTALL-WINDOWS-FULL-REG-TESTS" class="id_link">#</a></h3></div></div></div><p>246   To run the regression tests, make sure you have completed the build of all247   required parts first. Also, make sure that the DLLs required to load all248   parts of the system (such as the Perl and Python DLLs for the procedural249   languages) are present in the system path. If they are not, set it through250   the <code class="filename">buildenv.pl</code> file. To run the tests, run one of251   the following commands from the <code class="filename">src\tools\msvc</code>252   directory:253</p><pre class="screen">254<strong class="userinput"><code>vcregress check</code></strong>255<strong class="userinput"><code>vcregress installcheck</code></strong>256<strong class="userinput"><code>vcregress plcheck</code></strong>257<strong class="userinput"><code>vcregress contribcheck</code></strong>258<strong class="userinput"><code>vcregress modulescheck</code></strong>259<strong class="userinput"><code>vcregress ecpgcheck</code></strong>260<strong class="userinput"><code>vcregress isolationcheck</code></strong>261<strong class="userinput"><code>vcregress bincheck</code></strong>262<strong class="userinput"><code>vcregress recoverycheck</code></strong>263<strong class="userinput"><code>vcregress taptest</code></strong>264</pre><p>265 266   To change the schedule used (default is parallel), append it to the267   command line like:268</p><pre class="screen">269<strong class="userinput"><code>vcregress check serial</code></strong>270</pre><p>271 272   <code class="command">vcregress taptest</code> can be used to run the TAP tests273   of a target directory, like:274</p><pre class="screen">275<strong class="userinput"><code>vcregress taptest src\bin\initdb\</code></strong>276</pre><p>277 278   For more information about the regression tests, see279   <a class="xref" href="regress.html" title="Chapter 33. Regression Tests">Chapter 33</a>.280  </p><p>281   Running the regression tests on client programs with282   <code class="command">vcregress bincheck</code>, on recovery tests with283   <code class="command">vcregress recoverycheck</code>, or TAP tests specified with284   <code class="command">vcregress taptest</code> requires an additional Perl module285   to be installed:286   </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="productname">IPC::Run</span></span></dt><dd><p>287      As of this writing, <code class="literal">IPC::Run</code> is not included in the288      ActiveState Perl installation, nor in the ActiveState Perl Package289      Manager (PPM) library. To install, download the290      <code class="filename">IPC-Run-&lt;version&gt;.tar.gz</code> source archive from291      <acronym class="acronym">CPAN</acronym>,292      at <a class="ulink" href="https://metacpan.org/dist/IPC-Run" target="_top">https://metacpan.org/dist/IPC-Run</a>, and293      uncompress. Edit the <code class="filename">buildenv.pl</code> file, and add a PERL5LIB294      variable to point to the <code class="filename">lib</code> subdirectory from the295      extracted archive. For example:296</p><pre class="programlisting">297$ENV{PERL5LIB}=$ENV{PERL5LIB} . ';c:\IPC-Run-0.94\lib';298</pre><p>299     </p></dd></dl></div><p>300  </p><p>301   The TAP tests run with <code class="command">vcregress</code> support the302   environment variables <code class="varname">PROVE_TESTS</code>, that is expanded303   automatically using the name patterns given, and304   <code class="varname">PROVE_FLAGS</code>. These can be set on a Windows terminal,305   before running <code class="command">vcregress</code>:306</p><pre class="programlisting">307set PROVE_FLAGS=--timer --jobs 2308set PROVE_TESTS=t/020*.pl t/010*.pl309</pre><p>310   It is also possible to set up those parameters in311   <code class="filename">buildenv.pl</code>:312</p><pre class="programlisting">313$ENV{PROVE_FLAGS}='--timer --jobs 2'314$ENV{PROVE_TESTS}='t/020*.pl t/010*.pl'315</pre><p>316  </p><p>317    Additionally, the behavior of TAP tests can be controlled by a set of318    environment variables, see <a class="xref" href="regress-tap.html#REGRESS-TAP-VARS" title="33.4.1. Environment Variables">Section 33.4.1</a>.319  </p><p>320   Some of the TAP tests depend on a set of external commands that would321   optionally trigger tests related to them. Each one of those variables322   can be set or unset in <code class="filename">buildenv.pl</code>:323   </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="varname">GZIP_PROGRAM</code></span></dt><dd><p>324      Path to a <span class="application">gzip</span> command. The default is325      <code class="literal">gzip</code>, which will search for a command by that326      name in the configured <code class="envar">PATH</code>.327     </p></dd><dt><span class="term"><code class="varname">LZ4</code></span></dt><dd><p>328      Path to a <span class="application">lz4</span> command. The default is329      <code class="literal">lz4</code>, which will search for a command by that330      name in the configured <code class="envar">PATH</code>.331     </p></dd><dt><span class="term"><code class="varname">OPENSSL</code></span></dt><dd><p>332      Path to an <span class="application">openssl</span> command. The default is333      <code class="literal">openssl</code>, which will search for a command by that334      name in the configured <code class="envar">PATH</code>.335     </p></dd><dt><span class="term"><code class="varname">TAR</code></span></dt><dd><p>336      Path to a <span class="application">tar</span> command. The default is337      <code class="literal">tar</code>, which will search for a command by that338      name in the configured <code class="envar">PATH</code>.339     </p></dd><dt><span class="term"><code class="varname">ZSTD</code></span></dt><dd><p>340      Path to a <span class="application">zstd</span> command. The default is341      <code class="literal">zstd</code>, which will search for a command by that342      name in the configured <code class="envar">PATH</code>.343     </p></dd></dl></div><p>344  </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 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> Chapter 19. Server Setup and Operation</td></tr></table></div></body></html>
codekingpro/portable-devtools · Team Ai