Although PostgreSQL is written for Unix-like operating systems, the C client library (libpq) and the interactive terminal (psql) can be compiled natively under Windows. The makefiles included in the source distribution are written for Microsoft Visual C++ and will probably not work with other systems. It should be possible to compile the libraries manually in other cases.
Tip: If you are using Windows 98 or newer you can build and use all of PostgreSQL "the Unix way" if you install the Cygwin toolkit first. In that case see Chapter 14.
To build everything that you can on Windows, change into the src directory and type the command
nmake /f win32.mak
This assumes that you have Visual C++ in your path.
The following files will be built:
The dynamically linkable frontend library
Import library to link your programs to libpq.dll
Static library version of the frontend library
The PostgreSQL interactive terminal
The only file that really needs to be installed is the libpq.dll library. This file should in most cases be placed in the WINNT\SYSTEM32 directory (or in WINDOWS\SYSTEM on a Windows 95/98/ME system). If this file is installed using a setup program, 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 plan 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 compilers 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.)
psql is compiled as a "console application". As the Windows console windows use a different encoding than the rest of the system, you must take special care when using 8-bit characters at the psql prompt. When psql detects a problematic console code page, it will warn you at startup. To change the console code page, two things are neccessary:
Set the code page by entering cmd.exe /c chcp 1252. (1252 is a code page that is appropriate for German; replace it with your value.) If you are using Cygwin, you can put this command in /etc/profile.
Set the console font to "Lucida Console", because the raster font does not work with the ANSI code page.