This page in other versions: Unsupported versions: 8.3 / 8.4

16.1. Building with Visual C++ 2005

The tools for building using Visual C++ 2005, are in the src/tools/msvc directory. When building, make sure there are no tools from MinGW or Cygwin present in your system PATH. Also, make sure you have all the required Visual C++ tools available in the PATH, usually by starting a Visual Studio Command Prompt and running the commands from there. All commands should be run from the src\tools\msvc directory.

Before you build, edit the file to reflect the configuration options you want set, including the paths to libraries used. If you need to set any other environment variables, create a file called 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:

   $ENV{PATH}=$ENV{PATH} . ';c:\some\where\bison\bin';

16.1.1. Requirements

PostgreSQL will build using either the professional versions (any edition) or the free Express edition of Visual Studio 2005. The following additional products are required to build the complete package. Use the file to specify which directories the libraries are available in.

ActiveState Perl

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 (Note: version 5.8 or later is required, the free Standard Distribution is sufficient).

ActiveState TCL

Required for building PL/TCL (Note: version 8.4 is required, the free Standard Distribution is sufficient).

Bison and Flex

Bison and Flex are required to build from Git, but not required when building from a release file. Note that only Bison 1.875 or versions 2.2 and later will work. Bison and Flex can be downloaded from


Diff is required to run the regression tests, and can be downloaded from


Gettext is required to build with NLS support, and can be downloaded from Note that binaries, dependencies and developer files are all needed.

Microsoft Platform SDK

It is recommended that you upgrade to the latest available version of the Microsoft Platform SDK, available for download from

MIT Kerberos

Required for Kerberos authentication support. MIT Kerberos can be downloaded from

libxml2 and libxslt

Required for XML support. Binaries can be downloaded from or source from Note that libxml2 requires iconv, which is available from the same download location.


Required for SSL support. Binaries can be downloaded from or source from


Required for UUID-OSSP support (contrib only). Source can be downloaded from


Required for building PL/Python. Binaries can be downloaded from


Required for compression support in pg_dump and pg_restore. Binaries can be downloaded from

16.1.2. Building

To build all of PostgreSQL in release configuration (the default), run the command:


To build all of PostgreSQL in debug configuration, run the command:

         build DEBUG

To build just a single project, for example psql, run the commands:

         build psql
         build DEBUG psql

To change the default build configuration to debug, put the following in the file:


It is also possible to build from inside the Visual Studio GUI. In this case, you need to run:


from the command prompt, and then open the generated pgsql.sln (in the root directory of the source tree) in Visual Studio.

16.1.3. Cleaning and installing

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 clean.bat command, which will automatically clean out all generated files. You can also run it with the dist parameter, in which case it will behave like make distclean and remove the flex/bison output files as well.

By default, all files are written into a subdirectory of the debug or release directories. To install these files using the standard layout, and also generate the files required to initialize and use the database, run the command:

         perl c:\destination\directory

16.1.4. Running the regression tests

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 file. To run the tests, run one of the following commands from the src\tools\msvc directory:

         vcregress check
         vcregress installcheck
         vcregress plcheck
         vcregress contribcheck

To change the schedule used (default is the parallel), append it to the command line like:

         vcregress check serial

For more information about the regression tests, see Chapter 29.

16.1.5. Building the documentation

Building the PostgreSQL documentation in HTML format requires several tools and files. Create a root directory for all these files, and store them in the subdirectories in the list below.

OpenJade 1.3.1-2

Download from and uncompress in the subdirectory openjade-1.3.1.

DocBook DTD 4.2

Download from and uncompress in the subdirectory docbook.

DocBook DSSSL 1.79

Download from and uncompress in the subdirectory docbook-dsssl-1.79.

ISO character entities

Download from and uncompress in the subdirectory docbook.

Edit the file, and add a variable for the location of the root directory, for example:


To build the documentation, run the command builddoc.bat. Note that this will actually run the build twice, in order to generate the indexes. The generated HTML files will be in doc\src\sgml.

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group