1 <!-- $PostgreSQL: pgsql/doc/src/sgml/install-win32.sgml,v 1.44 2007/12/19 12:29:36 mha Exp $ -->
3 <chapter id="install-win32">
4 <title>Installation on <productname>Windows</productname></title>
7 <primary>installation</primary>
8 <secondary>on Windows</secondary>
12 It is recommended that most users download the binary distribution for
13 Windows, available as a <productname>Windows Installer</productname> package
14 from the <productname>PostgreSQL</productname> website. Building from source
15 is only intended for people developing <productname>PostgreSQL</productname>
20 There are several different ways of building PostgreSQL on
21 <productname>Windows</productname>. The complete system can
22 be built using <productname>MinGW</productname> or
23 <productname>Visual C++ 2005</productname>. It can also be
24 built for older versions of <productname>Windows</productname> using
25 <productname>Cygwin</productname>. Finally, the client access library
26 (<application>libpq</application>) can be built using
27 <productname>Visual C++ 7.1</productname> or
28 <productname>Borland C++</productname> for compatibility with statically
29 linked applications built using these tools.
33 Building using <productname>MinGW</productname> or
34 <productname>Cygwin</productname> uses the normal build system, see
35 <xref linkend="installation"> and the FAQs in
36 <filename>doc/FAQ_MINGW</filename> and <filename>do/FAQ_CYGWIN</filename>.
37 Note that <productname>Cygwin</productname> is not recommended, and should
38 only be used for older versions of <productname>Windows</productname> where
39 the native build does not work, such as
40 <productname>Windows 98</productname>.
43 <sect1 id="install-win32-full">
44 <title>Building with <productname>Visual C++ 2005</productname></title>
47 The tools for building using <productname>Visual C++ 2005</productname>,
48 are in the <filename>src/tools/msvc</filename> directory. When building,
49 make sure there are no tools from <productname>MinGW</productname> or
50 <productname>Cygwin</productname> present in your system PATH. Also, make
51 sure you have all the required Visual C++ tools available in the PATH,
52 usually by starting a <application>Visual Studio Command Prompt</application>
53 and running the commands from there. All commands should be run from the
54 <filename>src\tools\msvc</filename> directory.
58 Before you build, edit the file <filename>config.pl</filename> to reflect the
59 configuration options you want set, including the paths to libraries used.
60 If you need to set any other environment variables, create a file called
61 <filename>buildenv.pl</filename> and put the required commands there. For
62 example, to add the path for bison when it's not in the PATH, create a file
65 $ENV{PATH}=$ENV{PATH} . ';c:\some\where\bison\bin';
70 <title>Requirements</title>
72 PostgreSQL will build using either the professional versions (any edition)
73 or the free Express edition of
74 <productname>Visual Studio 2005</productname>. The following additional products
75 are required to build the complete package. Use the
76 <filename>config.pl</filename> to specify which directories the libraries
81 <term><productname>ActiveState Perl</productname></term>
83 ActiveState Perl is required to run the build generation scripts. MinGW
84 or Cygwin Perl will not work. It must also be present in the PATH.
85 Binaries can be downloaded from
86 <ulink url="http://www.activestate.com"></>.
91 <term><productname>ActiveState TCL</productname></term>
93 Required for building <application>PL/TCL</application>.
98 <term><productname>Bison</productname> and
99 <productname>Flex</productname></term>
101 Bison and Flex are required to build from CVS, but not required when
102 building from a release file. Note that only Bison 1.875 or versions
103 2.2 and later will work. Bison and Flex can be
104 downloaded from <ulink url="http://gnuwin32.sourceforge.net"></>.
109 <term><productname>Diff</productname></term>
111 Diff is required to run the regression tests, and can be downloaded
112 from <ulink url="http://gnuwin32.sourceforge.net"></>.
117 <term><productname>Gettext</productname></term>
119 Gettext is required to build with NLS support, and can be downloaded
120 from <ulink url="http://gnuwin32.sourceforge.net"></>. Note that binaries,
121 dependencies and developer files are all needed.
126 <term><productname>Microsoft Platform SDK</productname></term>
128 It is recommended that you upgrade to the latest available version
129 of the <productname>Microsoft Platform SDK</productname>, available
130 for download from <ulink url="http://www.microsoft.com/downloads/"></>.
135 <term><productname>MIT Kerberos</productname></term>
137 Required for Kerberos authentication support. MIT Kerberos can be
139 <ulink url="http://web.mit.edu/Kerberos/dist/index.html"></>.
144 <term><productname>libxml2</productname> and
145 <productname>libxslt</productname></term>
147 Required for XML support. Binaries can be downloaded from
148 <ulink url="http://zlatkovic.com/pub/libxml"></> or source from
149 <ulink url="http://xmlsoft.org"></>. Note that libxml2 requires iconv,
150 which is available from the same download location.
155 <term><productname>openssl</productname></term>
157 Required for SSL support. Binaries can be downloaded from
158 <ulink url="http://www.slproweb.com/products/Win32OpenSSL.html"></>
159 or source from <ulink url="http://www.openssl.org"></>.
164 <term><productname>Python</productname></term>
166 Required for building <application>PL/Python</application>. Binaries can
167 be downloaded from <ulink url="http://www.python.org"></>.
172 <term><productname>zlib</productname></term>
174 Required for compression support in <application>pg_dump</application>
175 and <application>pg_restore</application>. Binaries can be downloaded
176 from <ulink url="http://www.zlib.net"></>.
185 <title>Building</title>
188 To build all of PostgreSQL in release configuration (the default), run the
195 To build all of PostgreSQL in debug configuration, run the command:
201 To build just a single project, for example psql, run the commands:
210 To change the default build configuration to debug, put the following
211 in the <filename>buildenv.pl</filename> file:
214 $ENV{CONFIG}="Debug";
220 It is also possible to build from inside the Visual Studio GUI. In this
221 case, you need to run:
227 from the command prompt, and then open the generated
228 <filename>pgsql.sln</filename> (in the root directory of the source tree)
234 <title>Cleaning and installing</title>
237 Most of the time, the automatic dependency tracking in Visual Studio will
238 handle changed files. But if there have been large changes, you may need
239 to clean the installation. To do this, simply run the
240 <filename>clean.bat</filename> command, which will automatically clean out
245 By default, all files are written into a subdirectory of the
246 <filename>debug</filename> or <filename>release</filename> directories. To
247 install these files using the standard layout, and also generate the files
248 required to initialize and use the database, run the command:
251 perl install.pl c:\destination\directory
258 <title>Running the regression tests</title>
261 To run the regression tests, make sure you have completed the build of all
262 required parts first. Also, make sure that the DLLs required to load all
263 parts of the system (such as the Perl and Python DLLs for the procedural
264 languages) are present in the system path. If they are not, set it through
265 the <filename>buildenv.pl</filename> file. To run the tests, run one of
266 the following commands from the <filename>src\tools\msvc</filename>
273 vcregress installcheck
279 vcregress contribcheck
283 To change the schedule used (default is the parallel), append it to the
287 vcregress check serial
291 For more information about the regression tests, see
292 <xref linkend="regress">.
297 <title>Building the documentation</title>
300 Building the PostgreSQL documentation in HTML format requires several tools
301 and files. Create a root directory for all these files, and store them
302 in the subdirectories in the list below.
305 <term>OpenJade 1.3.1-2</term>
308 <ulink url="http://sourceforge.net/project/downloading.php?groupname=openjade&filename=openjade-1_3_1-2-bin.zip"></>
309 and uncompress in the subdirectory <filename>openjade-1.3.1</filename>.
314 <term>DocBook DTD 4.2</term>
317 <ulink url="http://www.oasis-open.org/docbook/sgml/4.2/docbook-4.2.zip"></>
318 and uncompress in the subdirectory <filename>docbook</filename>.
323 <term>DocBook DSSSL 1.79</term>
326 <ulink url="http://sourceforge.net/project/downloading.php?groupname=docbook&filename=docbook-dsssl-1.79.zip"></>
327 and uncompress in the subdirectory
328 <filename>docbook-dsssl-1.79</filename>.
333 <term>ISO character entities</term>
336 <ulink url="http://www.oasis-open.org/cover/ISOEnts.zip"></> and
337 uncompress in the subdirectory <filename>docbook</filename>.
341 Edit the <filename>buildenv.pl</filename> file, and add a variable for the
342 location of the root directory, for example:
344 $ENV{DOCROOT}='c:\docbook';
346 To build the documentation, run the command
347 <filename>builddoc.bat</filename>. Note that this will actually run the
348 build twice, in order to generate the indexes. The generated HTML files
349 will be in <filename>doc\src\sgml</filename>.
355 <sect1 id="install-win32-libpq">
356 <title>Building <application>libpq</application> with
357 <productname>Visual C++</productname> or
358 <productname>Borland C++</productname></title>
361 Using <productname>Visual C++ 7.1-8.0</productname> or
362 <productname>Borland C++</productname> to build libpq is only recommended
363 if you need a version with different debug/release flags, or if you need a
364 static library to link into an application. For normal use the
365 <productname>MinGW</productname> or
366 <productname>Visual Studio 2005</productname> version is recommended.
370 To build the <application>libpq</application> client library using
371 <productname>Visual Studio 7.1 or later</productname>, change into the
372 <filename>src</filename> directory and type the command
374 <userinput>nmake /f win32.mak</userinput>
378 To build a 64-bit version of the <application>libpq</application>
379 client library using <productname>Visual Studio 8.0 or
380 later</productname>, change into the <filename>src</filename>
381 directory and type in the command
383 <userinput>nmake /f win32.mak CPU=AMD64</userinput>
385 See the <filename>win32.mak</filename> file for further details
386 about supported variables.
390 To build the <application>libpq</application> client library using
391 <productname>Borland C++</productname>, change into the
392 <filename>src</filename> directory and type the command
394 <userinput>make -N -DCFG=Release /f bcc32.mak</userinput>
399 <title>Generated files</title>
401 The following files will be built:
405 <term><filename>interfaces\libpq\Release\libpq.dll</filename></term>
408 The dynamically linkable frontend library
414 <term><filename>interfaces\libpq\Release\libpqdll.lib</filename></term>
417 Import library to link your programs to <filename>libpq.dll</filename>
423 <term><filename>interfaces\libpq\Release\libpq.lib</filename></term>
426 Static version of the frontend library
435 Normally you do not need to install any of the client files. You should
436 place the <filename>libpq.dll</filename> file in the same directory
437 as your applications executable file. Do not install
438 <filename>libpq.dll</filename> into your Windows, System or System32
439 directory unless absolutely necessary.
440 If this file is installed using a setup program, it should
441 be installed with version checking using the
442 <symbol>VERSIONINFO</symbol> resource included in the file, to
443 ensure that a newer version of the library is not overwritten.
447 If you are planning to do development using <application>libpq</application>
448 on this machine, you will have to add the
449 <filename>src\include</filename> and
450 <filename>src\interfaces\libpq</filename> subdirectories of the source
451 tree to the include path in your compiler's settings.
455 To use the library, you must add the
456 <filename>libpqdll.lib</filename> file to your project. (In Visual
457 C++, just right-click on the project and choose to add it.)