Installation from Source Code on Windows
 
  installation
  on Windows
 
 
  It is recommended that most users download the binary distribution for 
  Windows, available as a one-click installer package
  from the PostgreSQL website. Building from source
  is only intended for people developing PostgreSQL
  or extensions.
 
 
  There are several different ways of building PostgreSQL on
  Windows. The simplest way to build with
  Microsoft tools is to intall a modern version of the
  Microsoft Platform SDK and use use the included
  compiler. It is also possible to build with the full
  Microsoft Visual C++ 2005 or 2008. In some cases
  that requires the installation of the Platform SDK
  in addition to the compiler.
 
 
  It is also possible to build PostgreSQL using the GNU compiler tools
  provided by MinGW, or using
  Cygwin for older versions of
  Windows.
 
 
  Finally, the client access library
  (libpq) can be built using
  Visual C++ 7.1 or 
  Borland C++ for compatibility with statically
  linked applications built using these tools.
 
 
  Building using MinGW or
  Cygwin uses the normal build system, see
   and the specific notes in
   and .
  These builds cannot generate 64-bit binaries.
  Cygwin is not recommended and should
  only be used for older versions of Windows where
  the native build does not work, such as 
  Windows 98. MinGW is
  only recommended if you are building other modules using it. The official
  binaries are built using Visual Studio.
 
 
  Building with Visual C++ or the
  Platform SDK
 
  PostgreSQL can be built using the Visual C++ compiler suite from Microsoft.
  These compilers can be either from Visual Studio,
  Visual Studio Express or recent versions of the
  Platform SDK. If you do not already have a
  Visual Studio environment set up, the easiest
  way us to use the compilers in the Platform SDK,
  which is a free download from Microsoft.
 
 
  PostgreSQL supports the compilers from
  Visual Studio 2005 and
  Visual Studio 2008. When using the Platform SDK
  only, or when building for 64-bit Windows, only
  Visual Studio 2008 is supported.
 
 
  The tools for building using Visual C++,
  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. In
  Visual Studio, start the
  Visual Studio Command Prompt. In the
  Platform SDK, start the
  CMD shell listed under the SDK on the Start Menu.
  If you wish to build a 64-bit version, you must use the 64-bit version of
  the command, and vice versa.
  All commands should be run from the src\tools\msvc
  directory.
 
 
  Before you build, you may need to edit the file config.pl
  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 config_default.pl,
  and then apply any changes from config.pl. For example,
  to specify the location of your Python installation,
  put the following in config.pl:
  
   $config->{python} = 'c:\python26';
  
  You only need to specify those parameters that are different from what's in
  config_default.pl.
 
 
  If you need to set any other environment variables, create a file called
  buildenv.pl 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';
  
 
 
  Requirements
  
   The following additional products are required to build
   PostgreSQL. Use the
   config.pl file to specify which directories the libraries
   are available in.
   
    
     Microsoft Platform SDK
     
      It is recommended that you upgrade to the latest available version
      of the Microsoft Platform SDK, available
      for download from >.
     
     
      You must always include the
      Windows Headers and Libraries part of the SDK.
      If you install the Platform SDK
      including the Visual C++ Compilers,
      you don't need Visual Studio to build.
     
    
    
     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 is required,
      the free Standard Distribution is sufficient).
     
    
   
  
  
   The following additional products are not required to get started,
   but are required to build the complete package. Use the
   config.pl file to specify which directories the libraries
   are available in.
   
    
     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 CVS, but not required when
      building from a release file. Note that only Bison 1.875 or versions
      2.2 and later will work. Also, Flex version 2.5.31 or later is required.
      Bison can be downloaded from >.
      Flex can be downloaded from 
      >.
     
    
    
     Diff
     
      Diff is required to run the regression tests, and can be downloaded
      from >.
     
    
    
     Gettext
     
      Gettext is required to build with NLS support, and can be downloaded
      from >. Note that binaries,
      dependencies and developer files are all needed.
     
    
    
     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.
     
    
    
     openssl
     
      Required for SSL support. Binaries can be downloaded from
      >
      or source from >.
     
    
    
     ossp-uuid
     
      Required for UUID-OSSP support (contrib only). Source can be 
      downloaded from
      >.
     
    
    
     Python
     
      Required for building PL/Python. Binaries can
      be downloaded from >.
     
    
    
     zlib
     
      Required for compression support in pg_dump
      and pg_restore. Binaries can be downloaded
      from >.
     
    
   
  
 
 
  Special considerations for 64-bit Windows
  
   PostgreSQL will only build for the x64 architecture on 64-bit Windows, there
   is no support for Itanium processors.
  
  
   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.
  
  
   To use a server-side third party library such as python> or
   openssl>, this library must 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.
  
 
 
  Building
  
   To build all of PostgreSQL in release configuration (the default), run the
   command:
   
    
     build
    
   
   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 buildenv.pl file:
   
    
     $ENV{CONFIG}="Debug";
    
   
  
  
   It is also possible to build from inside the Visual Studio GUI. In this
   case, you need to run:
   
    
     perl mkvcbuild.pl
    
   
   from the command prompt, and then open the generated
   pgsql.sln (in the root directory of the source tree)
   in Visual Studio.
  
 
 
  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:
   
    
     install c:\destination\directory
    
   
  
 
 
  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 buildenv.pl 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 parallel), append it to the
   command line like:
   
    
     vcregress check serial
    
   
   For more information about the regression tests, see
   .
  
 
 
  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 buildenv.pl file, and add a variable for the
   location of the root directory, for example:
   
    $ENV{DOCROOT}='c:\docbook';
   
   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.
  
 
 
 
  Building libpq with
  Visual C++ or
  Borland C++
 
  Using Visual C++ 7.1-9.0 or
  Borland C++ to build libpq is only recommended
  if you need a version with different debug/release flags, or if you need a
  static library to link into an application. For normal use the
  MinGW or
  Visual Studio or
  Platform SDK method is recommended.
 
 
  To build the libpq client library using
  Visual Studio 7.1 or later, change into the
  src directory and type the command:
nmake /f win32.mak
 
 
 To build a 64-bit version of the libpq
 client library using Visual Studio 8.0 or
 later, change into the src
 directory and type in the command:
nmake /f win32.mak CPU=AMD64
 See the win32.mak file for further details
 about supported variables.
 
 
  To build the libpq client library using
  Borland C++, change into the
  src directory and type the command:
make -N -DCFG=Release /f bcc32.mak
 
 
 Generated files
 
  The following files will be built:
  
   
    interfaces\libpq\Release\libpq.dll
    
     
      The dynamically linkable frontend library
     
    
   
  
   
    interfaces\libpq\Release\libpqdll.lib
    
     
      Import library to link your programs to libpq.dll
     
    
   
   
    interfaces\libpq\Release\libpq.lib
    
     
      Static version of the frontend library
     
    
   
  
 
 
  Normally you do not need to install any of the client files. You should
  place the libpq.dll file in the same directory
  as your applications executable file. Do not install
  libpq.dll into your Windows>,
  System> or System32> directory unless
  absolutely necessary.
  If this file is installed using a setup program, then it should
  be installed with version checking using the
  VERSIONINFO resource included in the file, to
  ensure that a newer version of the library is not overwritten.
 
 
  If you are planning to do development using libpq
  on this machine, you will have to add the
  src\include and
  src\interfaces\libpq subdirectories of the source
  tree to the include path in your compiler's settings.
 
 
  To use the library, you must add the
  libpqdll.lib file to your project.  (In Visual
  C++, just right-click on the project and choose to add it.)